Looping Through Subdirectories and Running a Command in Each
Solution 1:
for dir in ~/projects/git/*; do (cd "$dir" && git pull); done
Solution 2:
If you need it to be recursive:
find . -type d -name .git -exec sh -c "cd \"{}\"/../ && pwd && git pull" \;
This will descend into all the directories under the current one, and perform a git pull on those subdirectories that have a .git directory (you can limit it with -maxdepth
).