Skip to content

Instantly share code, notes, and snippets.

@KonradIT
Forked from douglas/update_git_repos.sh
Last active April 21, 2018 10:50
Show Gist options
  • Save KonradIT/b90e51a7b524531d80164bfd762f4c2f to your computer and use it in GitHub Desktop.
Save KonradIT/b90e51a7b524531d80164bfd762f4c2f to your computer and use it in GitHub Desktop.
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
echo "Pulling in latest changes for all repositories..."
for i in $(find . -name ".git" | cut -c 3-); do
echo "";
echo "Current repository: $i";
# We have to go to the .git parent directory to call the pull command
cd "$i";
cd ..;
# finally pull
branch_git=$(git branch | grep \* | cut -d ' ' -f2)
git pull origin $branch_git;
# 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