Created
June 22, 2019 17:17
-
-
Save FerraBraiZ/11d947c800692cabbec93419d32c979c to your computer and use it in GitHub Desktop.
One bash script to fetch from origin and do a hard reset on several branches, this script is useful if u work on several projects at same time and need to sync your local master's with your remote origin, usually github
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# EN - GIT AAPT stands for update the whole danm thing | |
# PT-BR - GIT AAPT significa Atualiza a porra toda | |
# | |
REPOSITORIES="$( cd /home/${USER}/public_html/ && pwd )" | |
IFS=$'\n' | |
for REPO in `ls "$REPOSITORIES/"` | |
do | |
if [ -d "$REPOSITORIES/$REPO" ] | |
then | |
echo "$REPO at `date`" | |
if [ -d "$REPOSITORIES/$REPO/.git" ] | |
then | |
echo "Directory changing: $REPO" | |
cd "$REPOSITORIES/$REPO" | |
echo "Checking out to master" | |
git checkout master | |
echo "Fetching origin" | |
git fetch origin | |
echo "Hard reseting the branch" | |
git reset --hard origin/master | |
else | |
echo "Skipping because it doesn't look like it has a .git folder." | |
fi | |
echo "Done at `date`" | |
echo | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment