在拉取请求时重命名分支 [英] Renaming a branch while on pull request

查看:92
本文介绍了在拉取请求时重命名分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Github上,您可以进行pull请求来为项目添加功能。一个人的贡献必须在一个分支上,如果请求被接受,它将被合并到项目的主分支(或类似分支)中。



现在,我在Github上提交了一个pull请求,我的贡献在名为 patch-1 的分支上。我可以通过本地修改分支的名称

  git branch -m patch-1 newname 

原则上,我也可以按照这个答案。这在实践中通过移除旧分支 patch-1 来完成,并用另一个名称 newname

是否允许在Github的分叉库上重命名分支 patch-1 拉请求?
或者它会引起pull请求管理上的问题?



有什么办法可以在分支是拉请求时在Github上的分支库上重命名分支?

解决方案

在git中重命名一个远程分支,就像您提供的链接所指示的,实际上只是删除了一个分支,然后用相同的提交散列推送一个新的名称。如果您为分支补丁1打开了拉取请求,那么当您删除该分支时,拉取请求将被关闭。

所以,不,您不能在不删除分支并删除拉取请求的情况下重新打开拉取请求来重命名分支。但是,没有任何东西阻止你这样做,用新名称推新分支,并创建新的请求。


On Github, you can make pull requests to add functionality to a project. One's contributions have to be on a branch that, if the request is accepted, will be merged into the master branch (or an analogous one) of the project.

Now, I submitted a pull request on Github and my contributions are on a branch called patch-1. I can modify the name of the branch locally by

git branch -m patch-1 newname

and in principle I can also rename it on my forked repo on Github by following the instruction found in this answer. This is done in practice by removing the old branch, patch-1 in my case, and repush it with a different name newname.

Is it allowed to rename the branch patch-1 on my forked repository on Github when it constitutes a pull request? Or it causes problems on the pull request management?

Is there any way to rename a branch on a forked repository on Github when that branch is a pull request?

解决方案

"Renaming" a remote branch in git, as indicated by the link you provided, is really just deleting a branch, followed by pushing a new one with the same commit hash but a new name. If you have a pull request open for branch patch-1, when you delete that branch, the pull request will be closed.

So, no you can't rename the branch with a pull request open without deleting the branch and removing the pull request. However, there's nothing stopping you from doing that, pushing a new branch with a new name, and creating a new pull request.

这篇关于在拉取请求时重命名分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆