Last active
May 21, 2024 18:33
-
-
Save phette23/7620214 to your computer and use it in GitHub Desktop.
Shell script to run `git pull` inside all subdirectories which are git repositories. I keep a number of projects in a folder & this helps me avoid manually updating each.
This file contains 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 fish | |
# similar script in Fish | |
# still under construction, need to quiet `git status` more effectively | |
function update -d 'Update git repo' | |
git stash --quiet | |
git pull | |
git stash apply --quiet | |
end | |
for dir in ./*/ | |
cd $dir | |
git status -sb 2>/dev/null | |
if [ $status -eq 0 ] | |
set_color red | |
echo "Updating $dir…" | |
set_color normal | |
update | |
end | |
cd .. | |
end |
This file contains 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 bash | |
for dir in ./*/ | |
do | |
cd ${dir} | |
git status >/dev/null 2>&1 | |
# check if exit status of above was 0, indicating we're in a git repo | |
[ $(echo $?) -eq 0 ] && echo "Updating ${dir%*/}..." && git pull | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment