跳转到内容

Work with branches and stashes

此内容尚不支持你的语言。

The branch widget in the main toolbar shows where you are and opens every branch operation. Local changes that would be overwritten by a switch go into a stash and come back afterwards. Branches, stash and cherry-pick: Works.

Click the branch name in the main toolbar, or choose Git › Branches…. The widget shows the branch with how far it is ahead of and behind its upstream (↑2 ↓1), or, while an operation waits for you, “Rebasing main”, “Merging main” or “Cherry-picking” with a warning sign.

The popup lists, with an empty filter:

  • at the top: Update Project…, Commit…, Push…, New Branch… and Checkout Tag or Revision…;
  • Recent (up to five, the current branch first), Local, Remote (one folder per remote) and Tags, which starts closed. Names with / are grouped into folders.

Type to filter the list. The footer names the keys: ↩ checkout, → more actions, ⌥↩ rebase onto, ⌘↩ merge into current.

  • New branch: New Branch… in the popup, or ⌥⌘N (CtrlAltN). It starts at the current commit. New Branch from ‘feature’… in a branch’s submenu starts it there.
  • Switch: select a branch and press ↩. Only the files that differ between the two branches change; unrelated local changes stay.
  • A remote branch: checking out origin/feature creates a local feature. It is not set to track origin/feature; set the upstream with git branch -u in the terminal or on the first push.
  • A tag or a commit: Checkout Tag or Revision… puts you on a detached HEAD.

When a checkout or merge would overwrite local changes, a popup names the files (“Local changes would be overwritten: …”) and offers Smart Checkout (stash, check out, unstash) (or Smart Merge) and Cancel.

Smart Checkout puts your changes, untracked files included, into a real Git stash named “Ferris IDEA smart checkout: main → feature”, switches, and applies the stash again. If applying conflicts, the conflicts view opens and the stash stays in the list, so nothing is lost.

Press → on a local branch for its submenu:

  • Checkout, New Branch from ‘…’…
  • Checkout and Rebase onto ‘main’, Rebase ‘main’ onto ‘…’, Merge ‘…’ into ‘main’
  • Compare with ‘main’, Show Diff with Working Tree
  • Push…, Rename… (F2), Delete
  • Mark as Favorite / Unmark as Favorite

Delete removes only branches that are merged, never the current branch and never by force. After you merge a branch from the popup, a question offers Delete branch ‘…’ or Keep ‘…’.

Favourites are listed first. Click the star on a row or press Space. main and master and their remote versions start as favourites; the list is kept in .ferris-idea/branch-favorites.toml.

  1. Choose Git › Stash Changes….
  2. Type a message (↑ brings back earlier ones). Tick Keep index (⌥K) to leave staged changes in place, or Include untracked files (⌥U).
  3. Confirm. Your working tree is clean.

To bring it back, choose Git › Unstash Changes…. The list shows your stashes, newest selected:

  • ↩ applies the stash and keeps it, ⇧↩ applies and drops it (pop), Delete drops it.
  • ⌘D shows what the stash contains, Base against Stash.

A stash that conflicts with your files opens the conflicts view: Merge, rebase and resolve conflicts.

Stashing single files, applying single files of a stash, and the shelf are not available.

  • “Local changes would be overwritten”: choose Smart Checkout, or commit or stash first.
  • Delete is refused: the branch is not merged into the current one. Merge it first, or delete it with git branch -D in the terminal if you are sure.
  • A new local branch does not show ahead/behind counts: it has no upstream yet; push it once.
Keyboard of
ActionShortcut
BranchGit.Rename.Local.BranchF2 or ⇧F6F2 or ShiftF6
Git › New Branch⌥⌘NCtrlAltN

Reading branches needs no right; creating, switching, merging, deleting branches and stashing need the right vcs-write.

  • git_branch_actionchangesdry run by defaultvcs-writeBranch operations of the branch popup: delete (merged local branches only, never the current one, never forced), rename, checkout_revision (detached HEAD; refused when local changes would be overwritten), checkout_and_rebase (stops on conflicts for git_rebase continue/abort), is_merged, compare (ahead/behind commits) or diff-worktree.
  • git_branch_favoritechangeswriteMarks (favorite: true), unmarks (false) or toggles (left out) a favourite branch, as the star of the branch popup and of the Git log's branches pane do.
  • git_branchesreadsLocal and remote-tracking branches with target commit; the current branch first and marked; reports a detached HEAD.
  • git_create_branchchangesvcs-writeCreate a local branch at a start revision (default HEAD) without switching to it.
  • git_stashchangesvcs-writeGit stashes: list them (newest first, also reports a stopped rebase, cherry-pick or merge), push the local changes (optionally with untracked files, a message and keep_index to leave the staged changes in the index), apply or pop a stash (pop drops it when it applied without conflicts) or drop it, or show the files a stash changes with their text before and in the stash.
  • git_switch_branchchangesdry run by defaultvcs-writeSwitch to a local branch: updates the files that differ between HEAD and the branch, keeps unrelated local changes and refuses (listing the paths) when local changes would be overwritten.