quinn
quinn

Reputation: 6008

Prevent git from "safe deleting" unmerged branches

When i run git branch -d branchname, it used to only delete the branch if it was merged into current HEAD. Now, it will also delete it if it was merged into the same branch on the remote. How can I get git to behave the way it used to?

Upvotes: 2

Views: 425

Answers (1)

torek
torek

Reputation: 489848

There is nothing built in to do this (other than to go back to using an older version of Git, of course).

If you're willing to stop using git branch -d entirely, though, the answer is simple enough. Write your own program that decides whether a deletion is safe, using whatever criteria you prefer. Use the existing Git tools (e.g., git branch --merged or git for-each-ref for the plumbing equivalent) to make this decision. Then, if your delbranch command or whatever you call it thinks the deletion is safe, you can invoke Git's own delete operation.

Upvotes: 4

Related Questions