Skip to content

Branches and remotes

Checkout, merge, rebase, push, pull, and pull requests.

Press 3 for the branches panel. The panel holds three tabs: local branches, remotes, and tags. Press ] or [ to change the tab.

Key Action
space Check out the branch under the cursor
c Check out a branch by name
F Check out, and throw away the local changes
- Go back to the branch you came from

c searches the branch names while you type, so a long name needs only a few letters.

CAUTION: F deletes the changes in your working tree. Use space first, and read what git says when it refuses.

  1. Move the cursor to the commit or the branch you want to start from.
  2. Press n.
  3. Type the name and press enter.
The new branch is created and checked out in one step.
Key Action
n New branch
R Rename the branch
d Delete the branch
N Move commits onto a new branch

Before it deletes, stage asks git whether the branch is contained in HEAD. A branch that is not merged needs a second confirmation.

Key Action
M Merge the branch under the cursor into the current one
r Rebase the current branch onto the branch under the cursor
f Fast-forward the branch under the cursor, without checking it out

A merge and a rebase can both stop on a conflict. Read Conflicts for the keys that finish them.

Key Action
p Pull
P Push
The ahead marker in the status panel clears when the push lands.

A branch with no upstream is published with -u origin <branch>, so the first push also sets the tracking branch.

If the remote moved, git rejects the push. stage then asks whether to push with --force-with-lease. It never sends that flag without your answer.

stage reads the result of a push from git push --porcelain, which marks a rejected ref with !. It does not read the message text, so a git in another language still gives the correct answer.

pullMode in the configuration decides this:

Value Result
auto stage adds no flag. Your pull.rebase and pull.ff settings decide
merge --no-rebase
rebase --rebase
ff-only --ff-only

auto is the default. Your git configuration already answers this question, and two answers in two places disagree sooner or later.

Press ] from the branches tab for the remotes.

Key Action
enter Show the branches of the remote
space Check out the remote branch
n Add a remote
e Change the URL of a remote
d Delete a remote
f Fetch
Key Action
o Create a pull request
O Pull request options
G Open the pull request in the browser
ctrl+y Copy the URL of the pull request

The branches panel marks a branch that has an open pull request.

github.com and gitlab.com need no configuration. For a self-hosted forge, add the host to services in the configuration. Read Configuration.

Press W on a branch to mark it. Every branch you select after that is compared against the mark. Press ctrl+t to open your difftool.