Skip to content

Instantly share code, notes, and snippets.

@nicholsonjf
Last active September 24, 2020 20:38
Show Gist options
  • Save nicholsonjf/e268114c5df633d538df4b8246034dc2 to your computer and use it in GitHub Desktop.
Save nicholsonjf/e268114c5df633d538df4b8246034dc2 to your computer and use it in GitHub Desktop.
#! /bin/sh
##
# Loops through all the objects in the current directory. If the object is a git repo it
# performs a "git pull --rebase" and "git checkout master".
#
# To use as a shell command:
#
# OSX:
# Place this file in /usr/local/bin
# Make the file executable: "chmod u+x checkout-master"
# Run the command by using just the filename: $ checkout-master
#
# Pop!OS:
# Switch to OSX and see above.
##
for directory in */; do
if [ -d "$directory"/.git ]; then
echo $directory
git -C $directory pull --rebase
git -C $directory checkout master
else
echo "$directory is not a git repo."
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment