Command: git co - arxanas/git-branchless Wiki

Description

git branchless checkout (aliased to git co by default) is a command to interactively search for and check out a commit.

It only works for commits which are visible in your smartlog (see git smartlog).

To quickly move between commits in the same stack, see git next and git prev.

The interactive selector is powered by Skim, so see there for more details on keyboard shortcuts and so forth.

Usage

Run git co to open the interactive commit selector:

Commit: c3a440f4fe7d932d21e8391ebf7d45f5057ef356
Author: Waleed Khan <[email protected]>
Date:   2021-11-07 11:59:46 -08:00
    Create baz

────────────────────────────────────────────────
  3bcf7176 3s (grault) Create grault
  5d98d4c8 3s Create qux
  682abc78 3s Update foo
  8a3fa867 3s Create xyzzy
> c3a440f4 3s (baz) Create baz
  6/6
> 

Then type a search term and press enter to check it out:

Commit: 682abc78cc57bc830ca013520523f4ccbe098fba
Author: Waleed Khan <[email protected]>
Date:   2021-11-07 11:59:46 -08:00
    Update foo

────────────────────────────────────────────────
  fcba6182 21m (master) Create foo
> 682abc78 3s Update foo
  2/6
> foo

You can use the arrow keys to disambiguate or ctrl-c to cancel.

Seeding with a search term

If you want to narrow down the search before opening the selector, pass an additional argument to git co:

$ git co foo
Commit: 682abc78cc57bc830ca013520523f4ccbe098fba
Author: Waleed Khan <[email protected]>
Date:   2021-11-07 11:59:46 -08:00
    Update foo

────────────────────────────────────────────────
  fcba6182 21m (master) Create foo
> 682abc78 3s Update foo
  2/6
> foo