by stinos · 7y ago · 0 comments
I've used multiple multiple repository tools and in the end all I happen to use is one (usually versioned) file to store a list of repositories and then a command which just loops over all repos and applies anything to it. If I need custom commands I use git aliases so that works both for normal git and whatever tool used.
→ cat ~/bin/git-all
#!/bin/bash
# Exit on error. Append "|| true" if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch the error in case command1 fails (but command2 succeeds) in `command1 |command2`
set -o pipefail
# Turn on traces, useful while debugging but commented out by default
# set -o xtrace
help() {
cat <<EOF
usage: git all <any-git-command>
Runs the git command for all repositories in the current directory.
Examples:
What just happened?
git all log -1 --oneline
What am I doing now?
git all status --short --branch
What is everything I'm working on?
git all branch -vv
EOF
}
banner() {
echo -e "\\033[1m=== $1 ===\\033[0m"
}
main() {
if (( $# < 1 )); then
help
exit 1
fi
folders=$(find . -maxdepth 2 -name .git -print0 | xargs -0 -n1 dirname)
for folder in $folders;
do
banner "$folder"
git -C "$folder" "$@" || true
done
}
main "$@"But I do see the convenience in your proposal
gita super <repo-name> <any command/alias>
For example:
gita super repo2 commit -am 'fix a bug'