Skip to content

Instantly share code, notes, and snippets.

@benjefferies
Last active June 13, 2018 08:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjefferies/f95a4f0d452805c7174e630848cc8290 to your computer and use it in GitHub Desktop.
Save benjefferies/f95a4f0d452805c7174e630848cc8290 to your computer and use it in GitHub Desktop.
A bash script to change to master branch on all repos and pull within a base directory. Inspired by https://gist.github.com/douglas/1287372
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "Pulling in latest changes for 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 "$i";
# We have to go to the .git parent directory to call the pull command
cd "$i";
cd ..;
# finally pull
git fetch
git reset --hard
git checkout master
git pull origin master;
# lets get back to the CUR_DIR
cd $CUR_DIR
done
echo "Complete!"
@benjefferies
Copy link
Author

Run with bash < <(curl -s https://gist.githubusercontent.com/benjefferies/f95a4f0d452805c7174e630848cc8290/raw/bc934c4b5623f883c41bbac2908f4a4e8ea1d91a/change_to_master_and_update.sh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment