79 points · by nosarthur · 7y ago · 36 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'
mr register in the root of a git dir.
then `mr status` from home will show the state of all repo's registered, it's handy at the eod to see what repos you've touched but not committed.
I currently use a mix of mu-repo [1] and uncommitted [2]
For example, let's say that I have a release 1.0, which consists of a bunch of commit IDs of various repositories. How do I go back to that release without manually checking out the specific commit ID in each repo?
Very convenient. I have used it for ROS projects with multiples SCM
I haven't done that since using SVN 10 years ago.
`git {branch,diff,stash}` should be all you need for this.
Especially working with the stash will be a big productivity boost for you.
What else do you think is a fad? Linux? C?