For the most part, git
has a different way of handling this situation (mainly: tag the branch, delete the branch) but, to answer the question you asked -- why would you want to? -- the answer is: to prevent the branch from changing.
Here's one example of when that's useful: A lot of SCM organizations create a branch when a product is getting near shipping, so that the branch can be under strict change control, but development can continue on master (/main/trunk/etc. in other environments).
So you might have, for example a branch dedicated to v2.1 which has been sent to QA before being shipped, and the only changes that will be allowed on the v2.1
branch will be those changes deemed by management important enough to include in v2.1. In the mean time, the rest of the team is working on master
, or branch v2.2
, or v2.5
, or Experimental-feature-branch
, etc.
Then v2.1
ships.
Again, in git, one typically just tags the thing that shipped (an important concept in SCM/SQA is to always be able to re-create the delivered build from the exact same sources that were used to create the one the customer has) but, since there's a branch with that name, wouldn't it be handy to "freeze" that branch at its end-of-life so that no one can change it further?
This is mostly a leftover from svn and similar other-environments. A git-centered shop would probably say "just tag it and delete the branch!", but old habits die hard, and people like to continue using the familiar, so they end up doing things like freezing the branch.
That's certainly how I arrived at this question looking for a way to freeze my git branch! :)