Skip to content

branch: let --delete-merged find squash merged branches - #2425

Draft
HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:branch-delete-squashed
Draft

HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:branch-delete-squashed

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Branches merged on GitHub with "Squash and merge" or "Rebase and merge" are never deleted by git branch --delete-merged, because their tips are not reachable from the upstream. This treats such a branch as merged when some upstream commit contains all of its changes, and names that commit in the output:

Deleted branch topic (was 1a2b3c4, landed as 9f8e7d6).

Branches merged on GitHub with "Squash and merge" or "Rebase and
merge" are never deleted by "git branch --delete-merged". The upstream
holds a rewritten copy of their work, so their tips are not reachable
from it and they look unmerged forever.

Treat such a branch as merged when some upstream commit since the fork
point contains all of its changes, so that merging the branch into
that commit would change nothing. Name that commit in the output so
the user can see where the work went:

    Deleted branch topic (was 1a2b3c4, landed as 9f8e7d6).

The first upstream commit that contains the changes is used, so the
branch is deleted even if upstream later reverted or reworked them.
Nothing is lost, since that commit keeps them in the upstream history.
A branch whose changes only partly landed is kept.

Signed-off-by: Harald Nordgren <[email protected]>

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