[英]Commits from different branch on GitHub Pull Request
I'm working with a fork of our company's app on GitHub. 我正在GitHub上使用我们公司的应用程序。 We have a develop branch and we are creating new branches from develop to work on like ( like
feature/new-feature
) and creating pull request to original repo when our work finished. 我们有一个developer分支,我们正在创建一个从development到work之类的新分支( 例如
feature/new-feature
),并在工作完成后向原始仓库创建拉取请求。 Of course doing a rebase before creating PR. 当然,在创建PR之前要进行变基。
After rebase some commits ( commitA and commitC ) from different developer merged to my branch. 重新设置基准后 ,来自不同开发人员的一些提交( commitA和commitC )合并到我的分支中。 And now in my PR these commits also listing as file changes.
现在在我的PR中,这些提交也作为文件更改列出。 And have conflict with develop.
与发展有冲突。
In shortly, My PR's commit list is like this: 不久,我的PR的提交列表如下:
commitA <---this commmit is different developers and shouldn't be listed here commitB commitC <---this commmit is different developers and shouldn't be listed here ...
How can I remove these commits from my PR? 如何从PR中删除这些提交? These commits (commitA and commitC) is also on develop branch.
这些提交(commitA和commitC)也在develop分支上。
My branch should have only commit B, commitA and commitC belongs to develop branch, not my branch. 我的分支应该只有commit B,commitA和commitC属于develop分支,而不是我的分支。
You can do a Git rebase in interactive mode, and then selectively remove the A
and C
commits which you don't want. 您可以在交互模式下进行Git变基,然后有选择地删除不需要的
A
和C
提交。 Assuming you want to see the last 5 commits during the rebase, you can do the following: 假设您希望在重新设置基准期间查看最近的5次提交,可以执行以下操作:
git rebase -i HEAD~5
This will open an editor containing a file looking something like the following: 这将打开一个包含如下文件的编辑器:
pick dl4mn23 commitA comment
pick 47kmeu6 commitB comment
pick k39fn39 commitC comment
pick lsw42fg commitD comment
pick mk837dc commitE comment
To remove the A
and C
commits, you can simply delete the corresponding lines, leaving you with this: 要删除
A
和C
提交,您只需删除相应的行,就可以了:
pick 47kmeu6 commitB comment
pick lsw42fg commitD comment
pick mk837dc commitE comment
Save the file and exit the editor, which should begin the rebase. 保存文件并退出编辑器,编辑器应开始重新设置基准。 You may have to resolve merge conflicts.
您可能必须解决合并冲突。 Once you have completed the rebase, you can verify that you have the history you want using
git log
. 完成变基后,您可以使用
git log
验证是否具有所需的历史git log
。
As one other note, since you rewrote the history of this branch, you will have to force push it to the remote via: 另一个要注意的是,由于您重写了该分支的历史记录,因此您将不得不通过以下方式强制将其推向远程:
git push origin feature --force
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.