Skip to content

Instantly share code, notes, and snippets.

Last active May 4, 2018 13:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
update git repositories included in a folder after resetting hard into a branch name passed as parameter (example: master)
# store the current dir
# retrieve base repo parameter
# 1st param: alias of the remote repo URL (example: origin)
# 2nd param: remote branch name (example: master)
# Let the person running the script know what's going on.
echo "....hard reset to " $BASE_REPO " and pulling latest into all repositories...."
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
echo "";
echo "....pulling repo: " $i "....";
# We have to go to the .git parent directory to call the pull command
cd "$i";
cd ..;
# reset to master before pull
git checkout master
git reset --hard $BASE_REPO
# finally pull
git pull origin master;
# lets get back to the CUR_DIR
echo "....Pulling all Repos COMPLETED!...."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment