Repository navigation
fix(delete-squashed-branches): preserve default branch and target branch - #1299
Merged
hyperupcall merged 2 commits intoDec 3, 2026
Merged
Conversation
spacewander
approved these changes
Dec 2, 2026
hyperupcall
requested changes
Dec 2, 2026
hyperupcall
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! Just had one nit.
hyperupcall
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1292
git-delete-squashed-branchescurrently iterates over every local branch inrefs/heads/without excluding the default branch. When changes from the default branch (e.g.main, or a custominit.defaultBranch/git-extras.default-branch) have been squash-merged or cherry-picked onto another target branch such as a release branch, runninggit delete-squashed-branchesdeletes the default branch.Changes:
$targetBranch,$(git_extra_default_branch), and the standard default branch names (main,master,trunk,svn) inbin/git-delete-squashed-branches, matchingbin/git-delete-merged-branches.git config --getcalls ingit_extra_default_branchwith|| trueso it remains safe underset -euo pipefailwhen neither config key is set.tests/git-delete-squashed-branches.batscovering default branch preservation,init.defaultBranch, andgit-extras.default-branch.Tested the installed script locally in Git Bash on Windows (reproducing the deletion before the change and verifying all three test cases pass after); relying on CI for Linux/macOS Bats and OpenBSD portability checks.
AI tools assisted with this contribution.