Let's say I have a develop branch. I create a feature branch from this to develop a feature. Once the feature is developed, it is merged back into develop. Pretty much like shown here:
Is there a way I can freeze the feature branch so that no further commits can be made to it?
The reason for not outright deleting the branch is so that viewing the history can still show the feature branch and that if there needs to be a tweak made to the feature then it is possible for someone to create a new feature branch from the last commit of the previous feature.
NAME. git-freeze - Freeze all changes on a branch (indexed and unindexed).
In your project, select the "Settings" tab on the far right of the menu. In the menu on the left hand side of the "Settings" page, select "Branches". Under the "Protected Branches" section, select any branch you wish from force push and deletion. Thanks!
Force a Checkout You can pass the -f or --force option with the git checkout command to force Git to switch branches, even if you have un-staged changes (in other words, the index of the working tree differs from HEAD ). Basically, it can be used to throw away local changes.
Christopher is right, tagging will help you do this. I recommend deleting the branch name too to make it a little harder for someone to checkout the branch and make edits.
First, merge the branch into develop
git checkout develop git merge --no-ff feature_1
Then checkout the branch
git checkout feature_1
Then create a tag, with a comment.
git tag -a -m "Freezing a feature branch that fixes.." feature_1_frozen
Then delete the branch
git checkout develop git branch -d feature_1
After doing this, you won't be able to checkout the branch by name. Instead you'll be able to checkout the tag by name, this will put you into a detached head state which will deter changes to the code.
Now to wrap things up and sync with origin...
Push the update and new tag
git push --tags origin develop
Delete the remote feature branch
git push origin :feature_1
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