Last active
May 29, 2020 20:52
-
-
Save egoens/0dbf32bcd9247e4a84e12cb356a1f07d to your computer and use it in GitHub Desktop.
Pull current repo and any immediate sub-repos
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
# pull subrepos | |
gplall () { | |
# look into immediate subdirectories | |
for dir in ./*/ | |
do | |
cd ${dir} | |
# check if exit status of above was 0, indicating we're in a git repo | |
if [ -d ".git" ] | |
then | |
# capture name of current branched checked out | |
curr_branch=`git rev-parse --abbrev-ref HEAD` | |
# checkout and pull master | |
echo "Updating ${dir%*/}..." && git checkout master && git pull | |
# checkout original branch if not 'master' | |
if [ "${curr_branch}" != "master" ] | |
then | |
echo "Checking out ${curr_branch} branch..." && git checkout "${curr_branch}" | |
fi | |
fi | |
cd .. | |
done | |
### update root repo | |
# capture name of current branched checked out | |
curr_branch=`git rev-parse --abbrev-ref HEAD` | |
# checkout and pull master | |
echo "Updating ${PWD##*/}..." && git checkout master && git pull | |
# checkout original branch if not 'master' | |
if [ "${curr_branch}" != "master" ] | |
then | |
echo "Checking out ${curr_branch} branch..." && git checkout "${curr_branch}" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment