Last active
September 9, 2017 21:08
-
-
Save Demonstrandum/fd5a75d7a47ab9facd7762dffbfd8094 to your computer and use it in GitHub Desktop.
Pull all your git repos to update them all
This file contains 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 | |
ORIGIN=$(pwd) | |
REPOROOT="$1" | |
if [ -z "$1" ]; then | |
REPOROOT="$HOME/Git" | |
if ! [ -d "$REPOROOT" ]; then | |
REPOROOT="$HOME/git" | |
fi | |
if ! [ -d "$REPOROOT" ]; then | |
printf "%s\n" \ | |
"No Git folder found!" \ | |
"Please specify a path to your git repos," \ | |
"e.g. \`pull-repos ~/MyGitRepos/\`" | |
exit 1 | |
fi | |
fi | |
REPOS="$(ls -l $REPOROOT | awk '{print $9}')" | |
cd "$REPOROOT" | |
for REPO in $REPOS; do | |
cd "$REPO" | |
printf "\nPulling: \'$REPO\'\n" | |
if [ -d "./.git/" ]; then | |
git reset --hard HEAD | |
git pull | |
fi | |
cd "$REPOROOT" | |
done | |
cd "$ORIGIN" | |
echo "Done, all repos pulled in $REPOROOT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
or run copy paste this in to a script and run it:
(
vim temp.bash
, copy, paste, thenbash temp.bash
)