Last active
December 24, 2024 04:20
-
-
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.
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added something to handle git submodules and not get tripped up by them.