Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete an (unmerged) Git branch when it is no longer active?

I have some maintenance branches in Git that were used to create emergency releases (i.e. to fix a critical bug in production). These branches are usually not merged back to master, because they either contain one-off fixes or have changes that were cherry-picked from master.

As a matter of practice, should these maintenance branches be deleted in Git if they are tagged (at build time)? Will deleting them cause those commits to be lost?

like image 706
Ken Liu Avatar asked Oct 21 '22 10:10

Ken Liu


1 Answers

No commit will be lost if it's reachable from a tag or a branch head.

If you tagged a branch, and then made another commit, and then deleted the branch, that last commit would be liable to garbage collection (at some point in the future - you can still recover it using reflog if you don't wait too long).

like image 159
Useless Avatar answered Oct 24 '22 03:10

Useless