Skip to main content

PyPi version Build Status codecov licence

Gita: a command-line tool to manage multiple git repos

This tool does two things

  • display the status of multiple git repos such as branch, modification, commit message side by side
  • delegate git commands/aliases from any working directory

If several repos need to be compiled against each other, it helps to see their status together. I also hate to change directories to execute git commands.

gita screenshot

Here the colors denote the 5 situations between local and remote branches:

  • white: local branch has no remote branch
  • green: local branch is the same as remote branch
  • red: local branch has diverged from remote branch
  • purple: local branch is ahead of remote branch (good for push)
  • yellow: local branch is behind remote branch (good for merge)

The choice of purple for ahead and yellow for behind is motivated by blueshift and redshift, using green as baseline.

The additional status symbols denote

  • +: staged changes
  • *: unstaged changes
  • _: untracked files/folders

The bookkeeping sub-commands are

  • gita add <repo-path(s)>: add repo(s) to gita
  • gita rm <repo-name>: remove repo from gita (won't remove repo from disk)
  • gita ls: display the status of all repos
  • gita ls <repo-name>: display the absolute path of one repo
  • gita -v: display gita version

Repo paths are saved in $XDG_CONFIG_HOME/gita/repo_path (most likely ~/.config/gita/repo_path).

The delegated git sub-commands are of two formats

  • gita <sub-command> [repo-name(s)] with optional input, and no input means all repos.
  • gita <sub-command> <repo-name(s)> with required repo name(s) input

By default, only fetch and pull take optional input. Sub-commands with required input include branch, clean, diff, difftool, log, merge, mergetool, patch, push, rebase, reflog, remote, stash, stat, and status.

If more than one repos are specified, the git command will run asynchronously, with the exception of difftool and mergetool, which require user input non-trivially.

Customization

Custom git commands/aliases can be placed in $XDG_CONFIG_HOME/gita/cmds.yml (most likely ~/.config/gita/cmds.yml). And they shadow the default ones if name collisions exist.

Delegation details for the default commands are in cmds.yml. For example, gita stat <repo-name(s)> is registered as

stat:
  cmd: diff --stat
  help: show edit statistics

which executes git diff --stat.

If the delegated git command is a single word, the cmd tag can be omitted. See push as an example. To disable asynchronous execution, set the disable_async tag to be true. See difftool as an example.

If you want a custom command to behave like gita fetch, i.e., to apply command to all repos if nothing is specified, set the allow_all option to be true. For example, the following snippet creates a new command gita comaster [repo-name(s)] with optional repo name input.

comaster:
  cmd: checkout master
  allow_all: true
  help: checkout the master branch

Superman mode

The superman mode delegates any git command/alias. Usage:

gita super [repo-name(s)] <command/alias>

Here repo-name(s) is optional, and absence means all repos. For example,

  • gita super myrepo1 commit -am 'fix a bug' executes git commit -am 'fix a bug' for myrepo1
  • gita super checkout master puts all repos on the master branch (also see the customization example)
  • gita super frontend_repo backend_repo checkout new-feature puts the two chosen repos on the new-feature branch

Requirements

Gita requires Python 3.6 or higher, due to the use of f-string and asyncio module.

Installation

To install the latest version, run

pip3 install -U gita

If development mode is preferred, download the source code and run pip3 install -e <gita-source-folder>. In either case, calling gita in terminal may not work, then you can put the following line in the .bashrc file.

alias gita="python3 -m gita"

Auto-completion

For auto completion, download .gita-completion.bash and source it in .bashrc.

Contributing

To contribute, you can

  • report/fix bugs
  • request/implement features
  • star/recommend this project

To run tests locally, simply pytest.

Other multi-repo tools

I haven't tried them but I heard good things about them.

Metadata

Release files for gita 0.7.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gita 0.7.8
File Size Uploaded Provenance Actions
gita-0.7.8.tar.gz 7.8 kB Without provenance Details for gita-0.7.8.tar.gz

Release files / gita-0.7.8.tar.gz

Download URL gita-0.7.8.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d6cbd2284571c5a62c116b5c473b38ce95eed020eb9481f5475ede193edbeef6
BLAKE2b-256 checksum
How to use checksums
9463ff11a84fa71bba2d22cc285b78b4c50a4b2c8cafa10e31dce2b5558a13b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

Security for gita 0.7.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.8 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page