go get -u github.com/giannimassi/git-checkout-interactive
If $GOBIN is available in your $PATH the command can be used as git checkout-interactive
.
You can also add the following to your .gitconfig
to provide a simpler to use alias for this command:
[alias]
cb = checkout-interactive --sort=-committerdate
After adding this alias you can simply call this to choose a branch from the latest ones:
git cb
This is just an example, you can add flags and arguments as needed in the alias.
git checkout-interactive <git branch arguments and flags>
Displays the current branch and allows to circle through branches listed with git branch
and the provided flag and arguments.
- press down/left/j to select next branch
- press up/right/h to select previous branch
- press enter to checkout selected branch
- press ESC or ctrl-c to exit without any changes
git checkout-interactive
Choose a branch to checkout among the local branches.
git checkout-interactive -a
Choose a branch to checkout among all branches, both local and remote.
git checkout-interactive --sort=-committerdate
Choose a branch to checkout among the local branches listed by most recent commit.