Created
December 30, 2021 09:40
-
-
Save exaV/7ce6b56b9ac1d15e290f0b50d98dc2df to your computer and use it in GitHub Desktop.
run a git command in all subdirectories
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
# output path to child directories which contain a .git folder | |
alias findgitdirs='find . -maxdepth 2 -type d -name ".git" | sed -e "s|/.git||"' | |
gitall(){ | |
# execute the argument as a git command in all (git) subdirectories | |
# if there are no arguments then print all of the directorries that would be used | |
if [ "$#" -eq 0 ]; then findgitdirs; return; fi | |
findgitdirs | xargs -I{} git -C {} "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment