Created
November 12, 2019 23:56
-
-
Save ginkgomzd/46cf4d4f67918912d462e578c1104ded to your computer and use it in GitHub Desktop.
bash function (such as you might put in .bash_aliases) to perform git commands on nested repos
This file contains 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
#!/bin/bash | |
gitsubs() { | |
gitsubs_max_depth=12 | |
echo searching for git repos | |
echo directory max-depth = $gitsubs_max_depth | |
echo executing git $@ | |
( # use a subshell and change the field-separator | |
# to allow for spaces in filenames | |
IFS=$'\n' | |
for d in `find . -maxdepth $gitsubs_max_depth -type d` | |
do | |
pushd $d >/dev/null; | |
# if directory contains a .git dir OR if is a bare-repo: | |
if [[ -d .git || $d == *.git && $(basename $d) != .git ]]; then | |
echo ".,.,.,.,. \\><((((*> [ $d ] <*))))></ "; echo | |
git $@; | |
echo "" | |
fi | |
popd &>/dev/null | |
done | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment