Package: gita
_______________________________
(  ____ \__   __|__   __(  ___  )
| (    \/  ) (     ) (  | (   ) |
| |        | |     | |  | (___) |
| | ____   | |     | |  |  ___  |
| | \_  )  | |     | |  | (   ) |
| (___) |__) (___  | |  | )   ( |
(_______)_______/  )_(  |/     \|   v0.16Gita: a command-line tool to manage multiple git reposThis tool has two main featuresdisplay the status of multiple git repos such as branch, modification, commit message side by side(batch) delegate git commands/aliases and shell commands on repos from any working directoryIn this screenshot, thegita llcommand displays the status of all repos.
Thegita remote dotfilescommand translates togit remote -vfor thedotfilesrepo, even though we are not in the repo.
Thegita fetchcommand fetches from all repos and two of them have updates.
To see the pre-defined commands, rungita -hor take a look atcmds.json.
To add your own commands, see thecustomization section.
To run arbitrarygitcommand, see thesuperman mode section.
To run arbitrary shell command, see theshell mode section.I also made a youtube video to demonstrate the common usagesThe branch color distinguishes 5 situations between local and remote branches:colormeaningwhitelocal has no remotegreenlocal is the same as remoteredlocal has diverged from remotepurplelocal is ahead of remote (good for push)yellowlocal is behind remote (good for merge)The choice of purple for ahead and yellow for behind is motivated byblueshiftandredshift,
using green as baseline.
You can change the color scheme using thegita colorcommand.
See thecustomization section.The additional status symbols denotesymbolmeaning+staged changes*unstaged changes?untracked files/folders$stashed contentsThe bookkeeping sub-commands aregita add <repo-path(s)> [-g <groupname>]: add repo(s) togita, optionally into an existing groupgita add -a <repo-parent-path(s)>: add repo(s) in <repo-parent-path(s)> recursively
and automatically generate hierarchical groups. See thecustomization sectionfor more details.gita add -b <bare-repo-path(s)>: add bare repo(s) togita. See thecustomization sectionfor more details on setting custom worktree.gita add -r <repo-parent-path(s)>: add repo(s) in <repo-parent-path(s)> recursivelygita clear: remove all groups and reposgita clone <URL>: clone repo fromURLat current working directorygita clone <URL> -C <directory>: change todirectoryand then clone repogita clone -f <config-file>: clone repos inconfig-file(generated bygita freeze) to current directory.gita clone -p -f <config-file>: clone repos inconfig-fileto prescribed paths.gita context: context sub-commandgita context: show current contextgita context <group-name>: set context togroup-name, all operations then only apply to repos in this groupgita context auto: set context automatically according to the current working directorygita context none: remove contextgita color: color sub-commandgita color [ll]: Show available colors and the current coloring schemegita color reset: Reset to the default coloring schemegita color set <situation> <color>: Use the specified color for the local-remote situationgita flags: flags sub-commandgita flags set <repo-name> <flags>: add customflagsto repogita flags [ll]: display repos with custom flagsgita freeze: print information of all repos such as URL, name, and path. Use withgita clone.gita group: group sub-commandgita group add <repo-name(s)> -n <group-name>: add repo(s) to a new or existing groupgita group [ll]: display existing groups with reposgita group ls: display existing group namesgita group rename <group-name> <new-name>: change group namegita group rm <group-name(s)>: delete group(s)gita group rmrepo <repo-name(s)> -n <group-name>: remove repo(s) from existing groupgita info: info sub-commandgita info [ll]: display the used and unused information itemsgita info add <info-item>: enable information itemgita info rm <info-item>: disable information itemgita ll: display the status of all reposgita ll <group-name>: display the status of repos in a groupgita ll -g: display the repo summaries by groupsgita ls: display the names of all reposgita ls <repo-name>: display the absolute path of one repogita rename <repo-name> <new-name>: rename a repogita rm <repo-name(s)>: remove repo(s) fromgita(won't remove files on disk)gita -v: display gita versionThegitdelegating sub-commands are of two formatsgita <sub-command> [repo-name(s) or group-name(s)]:
optional repo or group input, andno input means all repos.gita <sub-command> <repo-name(s) or groups-name(s)>:
required repo name(s) or group name(s) inputThey translate togit <sub-command>for the corresponding repos.
By default, onlyfetchandpulltake optional input. In other words,gita fetchandgita pullapply to all repos.
To see the pre-defined sub-commands, rungita -hor take a look atcmds.json.
To add your own sub-commands or override the default behaviors, see thecustomization section.
To run arbitrarygitcommand, see thesuperman mode section.If more than one repos are specified, thegitcommand runs asynchronously,
with the exception oflog,difftoolandmergetool,
which require non-trivial user input.Repo configuration global is saved in$XDG_CONFIG_HOME/gita/repos.csv(most likely~/.config/gita/repos.csv) or if you prefered at project configuration add environment variableGITA_PROJECT_HOME.InstallationTo install the latest version, runpip3 install -U gitaIf you prefer development mode, download the source code and runpip3 install -e <gita-source-folder>In either case, callinggitain terminal may not work,
then put the following line in the.bashrcfile.alias gita="python3 -m gita"Windows users may need to enable the ANSI escape sequence in terminal for
the branch color to work.
Seethis stackoverflow postfor details.Auto-completionYou can download the generated auto-completion file in the following locations for your specific shell. Alternatively, if you have installedargcompleteon your system, you can also directly runeval "$(register-python-argcomplete gita -s SHELL)"(e.g.SHELLasbash/zsh) in your dotfile.BashDownload.gita-completion.bashand source it in shell.ZshThere are 2 options :.gita-completion.zsh. Use the help of gita command to display options. It uses the bash completion system for zsh.
Addautoload -U +X bashcompinit && bashcompinitin .zshrc and source the zsh file_gita.
Completion more Zsh style. Copy it in a folder and add this folder path inFPATHvariable. This completion file doesn't take account to command from cmds.jsonFishDownloadgita.fishand place it in~/.config/fish/completions/Superman modeThe superman mode delegates anygitcommand or alias.
Usage:gita super [repo-name(s) or group-name(s)] <any-git-command-with-or-without-options>Hererepo-name(s)orgroup-name(s)are optional, and their absence means all repos.
For example,gita super checkout masterputs all repos on the master branchgita super frontend-repo backend-repo commit -am 'implement a new feature'executesgit commit -am 'implement a new feature'forfrontend-repoandbackend-repoShell modeThe shell mode delegates any shell command.
Usage:gita shell [repo-name(s) or group-name(s)] <any-shell-command>Hererepo-name(s)orgroup-name(s)are optional, and their absence means all repos.
For example,gita shell lllists contents for all reposgita shell repo1 repo2 mkdir docscreate a new directorydocsinrepo1andrepo2gita shell "git describe --abbrev=0 --tags | xargs git checkout": check out the latest tag for all reposCustomizationdefine repo group and contextWhen the project contains several independent but related repos,
we can define a group and executegitacommand on this group.
For example,gita group add repo1 repo2 -n my-group
gita ll my-group
gita pull my-groupTo save more typing, one can set a group as context, then anygitacommand
is scoped to the groupgita context my-group
gita ll
gita pullThe most useful context  maybeauto.
In this mode, the context is automatically determined from the
current working directory (CWD): the context is the group whose member repo's
path contains CWD. To set it, rungita context autoTo remove the context, rungita context noneIt is also possible to recursively add repos within a directory and
generate hierarchical groups automatically. For example, runninggita add -a srcon the following folder structuresrc
├── project1
│   ├── repo1
│   └── repo2
├── repo3
├── project2
│   ├── repo4
│   └── repo5
└── repo6gives rise to 3 groups:src:repo1,repo2,repo3,repo4,repo5,repo6
src-project1:repo1,repo2
src-project2:repo4,repo5add user-defined sub-command using json fileCustom delegating sub-commands can be defined in$XDG_CONFIG_HOME/gita/cmds.json(most likely~/.config/gita/cmds.json)
And they shadow the default ones if name collisions exist.Default delegating sub-commands are defined incmds.json.
For example,gita stat <repo-name(s)>is registered as"stat":{"cmd":"git diff --stat","help":"show edit statistics"}which executesgit diff --statfor the specified repo(s).To disable asynchronous execution, setdisable_asyncto betrue.
See thedifftoolexample:"difftool":{"cmd":"git difftool","disable_async":true,"help":"show differences using a tool"}If you want a custom command to behave likegita fetch, i.e., to apply to all
repos when no repo is specified, setallow_allto betrue.
For example, the following snippet creates a new commandgita comaster [repo-name(s)]with optional repo name input."comaster":{"cmd":"checkout master","allow_all":true,"help":"checkout the master branch"}Any command that runs in thesuperman modemode or theshell modecan be defined in this json format.
For example, the following command runs in shell mode and fetches only the
current branch from upstream."fetchcrt":{"cmd":"git rev-parse --abbrev-ref HEAD | xargs git fetch --prune upstream","allow_all":true,"shell":true,"help":"fetch current branch only"}customize the local/remote relationship coloring displayed by thegita llcommandYou can see the default color scheme and the available colors viagita color.
To change the color coding, usegita color set <situation> <color>.
The configuration is saved in$XDG_CONFIG_HOME/gita/color.csv.customize information displayed by thegita llcommandYou can customize the information displayed bygita ll.
The used and unused information items are shown withgita info, and the
configuration is saved in$XDG_CONFIG_HOME/gita/info.csv.For example, the default setting corresponds tobranch,commit_msg,commit_timeHerebranchincludes both branch name and status.
The status symbols are similar to the ones used inspaceship-prompt.To customize these symbols, add a file in$XDG_CONFIG_HOME/gita/symbols.csv.
The default settings corresponds todirty,staged,untracked,local_ahead,remote_ahead,diverged,in_sync,no_remote
*,+,?,↑,↓,⇕,,∅Only the symbols to be overridden need to be defined.
You can search unicode symbolshere.customize git command flagsOne can set custom flags to rungitcommands. For example, withgita flags set my-repo --git-dir=`gita ls dotfiles` --work-tree=$HOMEanygitcommand/alias triggered fromgitaondotfileswill use these flags.
Note that the flags are applied immediately aftergit. For example,gita st dotfilestranslates togit --git-dir=$HOME/somefolder --work-tree=$HOME statusrunning from thedotfilesdirectory.This feature was originally added to deal withbare repo dotfiles.RequirementsGita requires Python 3.6 or higher, due to the use off-stringandasyncio module.Under the hood, gita usessubprocessto run git commands/aliases.
Thus the installed git version may matter.
I have git1.8.3.1,2.17.2, and2.20.1on my machines, and
their results agree.Tipseffectshell commandenter<repo>directorycd `gita ls <repo>`delete repos in<group>gita group ll <group> | xargs gita rmContributingTo contribute, you canreport/fix bugsrequest/implement featuresstar/recommend this projectReadthis articleif you have never contribute code to open source project before.Chat room is available onTo run tests locally, simplypytestin the source code folder.
Note that context should be set asnone.
More implementation details are indesign.md.
A step-by-step guide to reproduce this project ishere.You can also sponsor me onGitHub. Any amount is appreciated!Other multi-repo toolsI haven't tried them but I heard good things about them.myreposrepomu-repo