Skip to content

Instantly share code, notes, and snippets.

@tueda
Created June 19, 2026 10:45
Show Gist options
  • Select an option

  • Save tueda/e538445f9c0cbd45130b788e509fd78d to your computer and use it in GitHub Desktop.

Select an option

Save tueda/e538445f9c0cbd45130b788e509fd78d to your computer and use it in GitHub Desktop.
Makefile snippet to run commands across Git repositories under the current directory. #make #makefile #git #linux
.PHONY: all status pull push
all:
status:
@first=:; \
for f in $$(find . -name '.git'); do \
d=$$(readlink -f "$$f/.."); \
if [ -d "$$d" ]; then \
if "$$first"; then \
first=false; \
else \
echo; \
fi; \
echo "$$d"; \
git -C "$$d" status; \
fi; \
done
pull:
@first=:; \
for f in $$(find . -name '.git'); do \
d=$$(readlink -f "$$f/.."); \
if [ -d "$$d" ]; then \
if "$$first"; then \
first=false; \
else \
echo; \
fi; \
echo "$$d"; \
git -C "$$d" pull --ff-only; \
fi; \
done
push:
@first=:; \
for f in $$(find . -name '.git'); do \
d=$$(readlink -f "$$f/.."); \
if [ -d "$$d" ]; then \
if "$$first"; then \
first=false; \
else \
echo; \
fi; \
echo "$$d"; \
git -C "$$d" push; \
fi; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment