When you branch some code, finish working with the branch, and merge it back to the trunk, what do you do with the branch? Delete it from the repository? Keep it for reference?
It seems like you would keep it for reference, but I imagine the /branches
directory could get pretty cluttered.
(If this isn't something people generally agree on, please comment and I'll make it a community wiki.)
jleedev
is right - we should specify which version control system we're talking about.
I had Subversion in mind, but would love to hear responses regarding other systems, too. Please specify which one you're answering about, or, <bribery>if you want to get the accepted answer</bribery>, compare and contrast several systems.
Now that I use Git, yes, I do delete branches when I'm finished with them. This is because in Git, a branch is nothing more than a label pointing to a specific commit.
When I first heard that, I didn't quite understand, but it's literally true. If you go into a project which you've got under Git version control and open .git/refs/heads
, you will see one file for each branch you have, including master. Each file contains the hash of a commit. That's it.
Obviously, creating such a file is very cheap, which is why branching is cheap in Git. That, in turn, is why I can branch often, and it would be silly to have branches like add_bells_to_the_widget
piling up everywhere.
Once a branch is merged into master, its commits are part of the master branch's history. The only purpose of keeping the branch would be to know which commit I considered that last one on a branch. And that's not very relevant to me when the code is in production.
I remove reintegrated branches since I do not need them any more. Git and Mercurial keep branching/merging history anyway. In subversion I'd keep old branches to have a reference to commit history.
I always prefer keeping the branches. Yes, I can use them as reference, or simply retrieve certain version any time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With