git - pull 请求成功后在 Git 中更改分支和删除分支

标签 git github

我从master创建了一个分支"newbranch",然后推回原点。然后我创建了一个 pull request,它被接受并 merge 到 master 中。

此时我应该从我的本地删除 "newbranch" 并从 master 重新 pull 以开始处理新的东西吗?

在一个分支被接受掌握后,正确的流程是什么?

最佳答案

2013 年 4 月更新:

参见“Redesigned merge button”和“What do you do with your branch after a pull request on GitHub?”:

分支现已为您删除

new merge button


原始答案(2013 年 2 月)

博文“Tidying up after Pull Requests”更加明确:

The only trouble is that we end up with a lot of defunct branches after Pull Requests have been merged or closed.
From time to time, one of us would clear out these branches with a script, but we thought it would be better to take care of this step as part of our regular workflow on GitHub.com.

Starting today, after a Pull Request has been merged, you’ll see a button to delete the lingering branch:

enter image description here

唯一不想删除该分支的情况是:

  • 如果您打算在当前补丁上进行扩展,请重复使用相同的分支
  • 或者您已经开始了一些尚未 merge/接受的提交,如果您删除了分支,这些提交将会丢失:

If the Pull Request was closed without being merged, the button will look a little different to warn you about deleting unmerged commits:

enter image description here

这样可以避免任何意外,过早删除分支。

关于git - pull 请求成功后在 Git 中更改分支和删除分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14903516/

相关文章:

git - 设置 Unity 智能 merge

git - 可以从即将删除的分支中剪切一个 git 分支吗?

git - 如何使 HEAD 和 origin/master 指向相同(最新)修订版。 (HEAD 指向最新版本,而 origin/master 指向过去版本)

git - 如何使用集线器从命令行 merge PR?

git - 如何修复 git 存储库中的 "bad date"问题?

git - git merge 是否考虑提交时间戳?

git - 根据新的 gitignore 从 git 跟踪文件中删除

git - 通过 git 从 github 获取 TYPO3 trunk

git - 如何在 Git 提交链上查看贡献者的电子邮件地址?

github - 使用 Octokit 获取某个日期范围内的拉取请求