git 在 GitHub 上拉取请求后,您如何处理您的分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7904038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What do you do with your branch after a pull request on GitHub?
提问by Randall
My team is experimenting with using GitHub pull requests for code reviews. My only question is what do you do with the branch after you're done? I would think you'd want to delete the branch, but since GitHub hides branches that have been merged into your current branch, it seemed like maybe I should keep it.
我的团队正在尝试使用 GitHub 拉取请求进行代码。我唯一的问题是你完成后如何处理分支?我认为您会想要删除该分支,但是由于 GitHub 隐藏了已合并到您当前分支中的分支,因此我似乎应该保留它。
Just curious on what your thoughts on best practices for this are.
只是想知道您对此最佳实践的想法是什么。
采纳答案by Bill Door
The rule of thumb that we use (which is here some where on Stack Overflow) is "branches are for work, tags are for history".
我们使用的经验法则(这是 Stack Overflow 上的一些地方)是“分支用于工作,标签用于历史”。
Whenever a branch is merged (most likely into master) we tag the merge point using the name of the branch with the prefix "branch" (e.g. branch-topic). Then delete the branch. If we need to resurrect work at the branch point we have the tag to be able to do that.
每当分支被合并(最有可能合并到主分支)时,我们使用带有前缀“branch”的分支名称(例如分支主题)标记合并点。然后删除分支。如果我们需要在分支点恢复工作,我们有标签可以做到这一点。
There are of course exceptions. We have long running branches that we use for various kinds of continuing work. But in general, topic branches are deleted after merging.
当然也有例外。我们有长期运行的分支,用于各种持续工作。但一般情况下,合并后主题分支会被删除。
On that note, those merges are always done with
在这一点上,这些合并总是用
merge --no-ff <branch>
This ensures that there is a merge point and a record of the merge occurring.
这确保有一个合并点和合并发生的记录。
回答by VonC
Note that since April, 10th 2013, "Redesigned merge button", the branch is deleted for you:
请注意,自 2013 年 4 月 10 日起,“重新设计合并按钮”,分支已为您删除:
Deleting branches after you merge has also been simplified.
Instead of confirming the delete with an extra step, we immediately remove the branch when you delete it and provide a convenient link to restore the branch in the event you need it again.
合并后删除分支也得到了简化。
我们不会通过额外的步骤确认删除,而是在您删除分支时立即删除它,并提供方便的链接以在您再次需要时恢复该分支。
That confirms the best practice of deleting the branch after merging a pull request.
这证实了合并拉取请求后删除分支的最佳实践。
回答by Fred Foo
I always delete branches that have been merged into master
. A Git branch, after all, is a pointer to a commit, and that commit is now available in the history of another branch, so I don't need the branch anymore. (You can always recreate the branch by looking at the parents of the merge commit.)
我总是删除已合并到master
. 毕竟,Git 分支是指向提交的指针,并且该提交现在在另一个分支的历史记录中可用,因此我不再需要该分支。(您始终可以通过查看合并提交的父项来重新创建分支。)