This is just a quick hack to add interactive a sort of fuzzy-matching interactive checkout for Git. The problem this solves is branches with ticket numbers in the name, which aren't as easy to memorize or auto-complete.
This requires fzf
, which can be installed from Github or homebrew.
$ brew install fzf
To install, just copy the corresponding lines from .gitconfig
into your Git config, and add the .githelpers
file to your home directory. If you already have an equivalent file, append the function and tweak the alias in .gitconfig
.
$ git branch
123-foo
234-bar
345-qux
$ git ci
> 123-foo
234-bar
345-qux
# Type foo and hit enter to checkout 123-foo
$ git ci foo
# Checks out 123-foo because it's the only match.
$ git ci 23
> 123-foo
234-bar
# Pre-filters 123-foo and 234-bar, but doesn't checkout due to ambiguity
$ git ci blah
# No match, no operation.