Skip to content

Instantly share code, notes, and snippets.

@olive42
Last active January 28, 2022 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olive42/9962f4bb43ad439ec4dc35929a2c06eb to your computer and use it in GitHub Desktop.
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 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://mylogin@git.server.example.com/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