Last active
January 28, 2022 09:18
-
-
Save olive42/9962f4bb43ad439ec4dc35929a2c06eb to your computer and use it in GitHub Desktop.
Figured an easy way to update a lot of checked out Git repositories in a given subtree (or whatever default you set in line 3).
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
# This assumes I am using zsh, and git config --global pull.rebase true | |
function gitupdate () { | |
# https://unix.stackexchange.com/questions/333862/how-to-find-all-git-repositories-within-given-folders-fast | |
find ${1:-.} -type d -path '*/.git' -printf '%h\n' -prune | xargs -t -I{} zsh -c "pushd {} && git fetch -p && git rev-parse --abbrev-ref --symbolic-full-name @{u} && | |
git pull ; popd" | |
git fetch -p && git pull | |
} | |
function gclone () { | |
pushd ~/src | |
git clone https://[email protected]/gitrepos/${1}.git | |
popd | |
} | |
cdpath+=(~/src) | |
alias gitcd='cd $(git rev-parse --show-toplevel)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment