Skip to content

Instantly share code, notes, and snippets.

Last active March 17, 2023 02:59
  • Star 17 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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.
#!/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
for dir in ./*/
cd $dir
git status -sb 2>/dev/null
if [ $status -eq 0 ]
set_color red
echo "Updating $dir…"
set_color normal
cd ..
#! /usr/bin/env bash
for dir in ./*/
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 ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment