Complementary command-line interface for Git.


Switch to a specified branch, stashing and restoring unstaged changes

$ git switch [target_branch]

Synchronize current branch, automatically merging or rebasing, and stashing and unstashing
$ git sync

Publish a specified branch to the remote server
$ git publish [branch_name]

Remove a branch from the remote server
$ git unpublish [branch_name]

List all branches and their publication status
$ git branches [glob_pattern]

Remove the last commit from the history
$ git undo [--hard]


GitHub for Mac is not just a Git client.

This comment on Hacker News says it best:

They haven't re-created the git CLI tool in a GUI, they've created something different. They've created a tool that makes Git more accessible. Little things like auto-stashing when you switch branches will confuse git veterans, but it will make Git much easier to grok for newcomers because of the assumptions it makes about your Git workflow.

Why not bring this innovation back to the command line?


switch <branch>

Switches to specified branch. Defaults to current branch. Automatically stashes and unstashes any changes. (alias: sw)

sync [<branch>]

Synchronizes the given branch. Defaults to current branch. Stash, Fetch, Auto-Merge/Rebase, Push, and Unstash. You can only sync published branches. (alias: sy)

publish [<branch>]

Publishes specified branch to the remote. (alias: pub)

unpublish <branch>

Removes specified branch from the remote. (alias: unp)


Un-does the last commit in git history. (alias: un)

branches [<wildcard pattern>]

Display a list of available branches. Allows wildcard pattern matching of branch name.


[image:] [image:] [image:] [image:]

From PyPI with the Python package manager:

pip install legit

Or download a standalone Windows executable from GitHub Releases.

To install the cutting edge version from the git repository:

git clone
cd legit
python install

Note: if you encountered Permission denied, prepend sudo before the pip or python command.

You'll then have the wonderful legit command available. Run it within a repository.

To view usage and examples, run legit with no commands or options:


To install the git aliases, run the following command:

legit --install

To uninstall the git aliases, run the following command:

legit --uninstall


All legit commands support --verbose and --fake options.

In order to view the git commands invoked by legit, use the --verbose option:

legit sync --verbose

If you want to see the git commands used by legit but don't want them invoked, use the --fake option:

legit publish --fake


  • All remote operations are carried out by the remote identified in $ git config legit.remote remotename

  • If a stash pop merge fails, Legit stops. I'd like to add checking for a failed merge, and undo the command with friendly error reporting.

Copied to clipboard