Skip to content

Instantly share code, notes, and snippets.

@petrilli
Last active December 24, 2024 04:20
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} -depth 2 -name ".git"); do
print -P "\n%F{green}= %F{white} Repo: ${i%.git}"
# Go to the .git parent directory to call the pull command
cd ${i}
cd ..
# finally pull
git pull origin
if [ -f ".gitmodules" ]; then
print -P "\n%F{green}= %F{white} Submodules for: ${i%.git}"
git submodule update --remote
fi
done
print -P "\n%F{green}=== Complete"
# Go back
popd
@petrilli
Copy link
Author

Added something to handle git submodules and not get tripped up by them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment