Created
June 19, 2026 10:45
-
-
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
This file contains hidden or 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
| .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