Skip to content

Allow deleting branches from the Commits panel - #6036

Open
seflue wants to merge 4 commits into
jesseduffield:masterfrom
seflue:delete-branch-from-commits-panel
Open

seflue wants to merge 4 commits into
jesseduffield:masterfrom
seflue:delete-branch-from-commits-panel

Conversation

@seflue

@seflue seflue commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

PR Description

Back to #4115 after a longer pause than planned. #4117 covered switching branches from the Commits pane,; this one continues with deleting them.

Pressing d on a commit now opens a menu instead of the "Drop commit" confirmation. The menu replaces the confirmation, as you suggested back then. The first entry drops the commit as before (still d, enter), followed by one entry per local branch pointing at the selected commit, and a "Delete branches" entry for all of them when there are several. Each opens the Branches panel's delete menu. The checked-out branch isn't offered since it can't be deleted anyway. When it is the only branch in the selection, the menu shows a disabled entry saying why, like the checkout menu from #4117.

A range of commits treats all branches found in the selection as a set. Handling this set works like a selection in the Branches panel. d is now also available while a cherry-pick or revert is in progress, and on a range that contains a merge commit. Since the commit(s) can't be dropped in those situations, the drop entry shows up disabled with the reason as its tooltip, as disabled entries do in the other menus. During a rebase, d still edits the todo without a menu. The warning about dropping merge commits moved into the tooltip of the drop entry.

The clipboard test used the drop confirmation as its stand-in for "any confirmation". Because that one is replaced by the menu, the test uses the stash drop confirmation now.

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

seflue and others added 4 commits September 24, 2026 20:36
The Commits panel is about to offer deleting a branch that points at the
selected commit, and it should present exactly the same local / remote /
both choice as the Branches panel does. Keeping the menu in
BranchesController would force the Commits panel to duplicate it, so
move it next to the confirmation helpers it calls.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
The Commits panel is about to get a second menu that lists the branches
pointing at the selected commit, with the same 1-9 keys and the same
disabled placeholder when there are none. Pull that part out so both
menus share it instead of copying it.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
The two halves are about to be needed separately: once `d` opens a
menu, the reasons that apply outside a rebase belong on the menu's
drop entry rather than on the keybinding, while the todo checks stay
on the keybinding because there is no menu mid-rebase.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
With git.log.showWholeGraph on, or in a stacked-branches workflow, the
Commits panel shows branch heads other than the checked-out branch, but
pruning one means finding it again in the Branches panel. Let the graph
be pruned where it is visible.

This is the panel's second delete operation, so both go behind `d`: the
drop confirmation becomes a menu whose first entry drops the commit
(still `d` and enter), followed by one entry per branch at the selected
commit(s), plus a "Delete branches" entry for all of them when there is
more than one. Those open the Branches panel's delete menu, which
already handles branches without an upstream. The checked-out branch is
not offered, since it can't be deleted anyway. The merge-commit warning
moves to the drop entry's tooltip.

A range of selected commits contributes all branches pointing at any of
them, the way a range in the Branches panel does. The reasons that used
to disable `d` outside a rebase (a merge commit in the range, a running
cherry-pick or revert) now sit on the drop entry instead, so that
branch deletion stays reachable in those states. Mid-rebase `d` still
edits the todo directly, without a menu.

The clipboard test used the drop confirmation as a stand-in for "any
confirmation popup"; since that confirmation no longer exists, it uses
the stash drop confirmation instead. The copy-to-clipboard behaviour
under test is unchanged.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@seflue
seflue force-pushed the delete-branch-from-commits-panel branch from 32db251 to 09a7fdd Compare September 24, 2026 18:36

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant