Reputation: 20554
Except for readability and clutter issues, should you remove git branches that will probably never be used again ? Does it improve git performance or has any effect on the total size of your repository ?
It's not a duplicate of Should I remove merged branches? because I don't want to know how to remove git branches, but only, why I should delete them.
Upvotes: 4
Views: 2731
Reputation: 176412
Unused branches contains changes and commits so they concur to the total size of your database.
When you delete a branch and the branch is not referenced anywhere else in the repository (for example there isn't a tag pointing to it), then git will be able to release the space used by the changes stored in the branch (immediately or after a garbage collection).
Whether you should remove the unused branches or not depends on whether you care to keep unused code around. If space is an issue, then you may want to delete them.
If space is not an issue, then you can keep them around as much as you want.
I personally delete unused branches because I don't like to have them around unless I don't need them for the following reasons:
I believe it's important to mention that if the branch is merged into master or it is contained in another branch (actually, master itself is a branch) then deleting it will not allow you reclaim the space. This is because 3 branches pointing to the same references use exactly the same amount of space (except for the very limited space required to save the branch metadata).
Upvotes: 3
Reputation: 9311
Good practice is to delete branches that are not used any more. It helps developers by not cluttering the repository with branches which no one use, and it helps git, by clearing space used by the branches. This also makes git clone and some other operations more faster.
Upvotes: 1