Skip to content
kain88-de edited this page May 4, 2024 · 8 revisions

Description

Available since v0.3.8. Renamed from git branchless checkout to git branchless switch in v0.6.0.

git branchless switch (aliased to git sw 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 sw -i to open the interactive commit selector:

Commit: c3a440f4fe7d932d21e8391ebf7d45f5057ef356
Author: Waleed Khan <me@waleedkhan.name>
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 <me@waleedkhan.name>
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.

Removed as of v0.7.0: As a shorthand, you can run git sw without any parameters to imply --interactive.

Seeding with a search term

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

$ git sw -i foo
Commit: 682abc78cc57bc830ca013520523f4ccbe098fba
Author: Waleed Khan <me@waleedkhan.name>
Date:   2021-11-07 11:59:46 -08:00
    Update foo

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