Skip to content

Instantly share code, notes, and snippets.

@aaronmelton
Last active November 25, 2023 14:17
Show Gist options
  • Save aaronmelton/c186f7699be7347d4d53860172426b18 to your computer and use it in GitHub Desktop.
Save aaronmelton/c186f7699be7347d4d53860172426b18 to your computer and use it in GitHub Desktop.
A simple shell script to loop through all sub-directories of current directory and perform a 'git pull' on each. This assumes all sub-directories are git repositories.
#!/usr/bin/env bash
base_dir=$PWD
# Loop through directories
for dir in */ ; do
[ -L "${dir%/}" ] && continue
this_dir=$base_dir/$dir
cd $this_dir
echo "-->$this_dir"
if [ -d .git ]; then
git pull
else
echo "Not a git directory."
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment