Skip to content

Instantly share code, notes, and snippets.

@petrilli
Created September 17, 2021 02:35
Show Gist options
  • Save petrilli/9842c09ca2abd3e955d3ff27e7efeaf9 to your computer and use it in GitHub Desktop.
Save petrilli/9842c09ca2abd3e955d3ff27e7efeaf9 to your computer and use it in GitHub Desktop.
Quick zsh script to update the multitude of git repositories I keep locally. Pretty brute force, but it works.
#!/usr/bin/env zsh
# Repository locations
REPOS=$HOME/src
# Keep our current directory on the stack
pushd
print -P "%F{green}=== %F{white}Pulling in the latest changes for all repositories in ${REPOS}..."
for i in $(find ${REPOS} -name ".git"); do
print -P "\n%F{green}= %F{white} Repo: ${i%.git}"
# We have to go to the .git parent directory to call the pull command
cd ${i}
cd ..
# finally pull
git pull origin
done
print -P "\n%F{green}=== Complete"
# Go back
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment