冻结Git分支 [英] Freezing a Git branch
问题描述
有没有一种方法可以冻结功能分支,以便不再进行任何提交?
不彻底删除分支的原因是,查看历史记录仍然可以显示功能分支,并且如果需要对功能进行调整,则可能有人创建从上一个功能的最后一次提交开始的一个新的功能分支。
克里斯托弗是对的,标记会帮助你做到这一点。我建议删除分支名称,以便让某人检出分支并进行编辑更难一些。
首先,将分支合并为develop
git checkout develop
git merge --no-ff feature_1
然后签出分行
git checkout feature_1
然后创建一个标签并附带评论。
git tag -a -m冻结修复了的功能分支..feature_1_frozen
然后删除分支
git checkout开发
git分支-d feature_1
完成此操作后,您将无法按名称检查分支。相反,您可以通过名称检出标签,这会使您进入独立的头部状态,从而阻止对代码进行更改。
现在包装起来并与原始同步......
推送更新和新标签
p> git push --tags origin develop
$ b $
$ b
删除远程功能分支$ c>
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.
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
这篇关于冻结Git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!