Last active
June 13, 2018 08:34
-
-
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
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 | |
# 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!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run with
bash < <(curl -s https://gist.githubusercontent.com/benjefferies/f95a4f0d452805c7174e630848cc8290/raw/bc934c4b5623f883c41bbac2908f4a4e8ea1d91a/change_to_master_and_update.sh)