4 ms·
Nice, but is there a way to just run any command? I.e. just `gita <optional repo names/paths> <pass entire command line git -C repodir>`. This has advantages in
by stinos 8y ago
Nice, but is there a way to just run any command? I.e. just `gita <optional repo names/paths> <pass entire command line git -C repodir>`. This has advantages in that you don't have to go round via a command file, don't have to keep it synced across machines, don't have to remember what you put in the file etc, and can just use the git syntax which already took long enough to learn by heart :P
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.
- nosarthur 8y agoThis is an interesting idea. I never thought about it before. My previous thinking is that if something really complex needs to be done, then I will go to that directory. But I do see the convenience in your proposal
- joshka 8y ago→ 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 "$@"
- stinos 8y agoMissed this reply, but yes, that's what I'm talking about!
- nosarthur 8y agoVersion 0.7.0 supports a super mode, which delegates any git command/alias. The usage is gita super <repo-name> <any command/alias> For example: gita super repo2 commit -am 'fix a bug'