简体   繁体   English

从GitHub Pull Request中的不同分支提交

[英]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. 重新设置基准后 ,来自不同开发人员的一些提交( commitAcommitC )合并到我的分支中。 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变基,然后有选择地删除不需要的AC提交。 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: 要删除AC提交,您只需删除相应的行,就可以了:

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.

相关问题 在 Github 上的拉取请求期间显示的每个分支的所有提交 - All Commits From Every Branch Displayed During Pull Request on Github github - 如何将提交转移到来自同一分支的另一个拉取请求 - github - how to divert commits to another pull request from the same branch 在分支上呈现提交的子集作为github pull请求 - Presenting a subset of commits on a branch as a github pull request Github请求请求排除&#39;合并分支&#39;提交 - Github pull request exclude 'merge branch' commits Github 从开发分支到主分支的拉取请求显示以前的提交。如何避免此类问题? - Github Pull Request from Develop branch to Master branch shows previous commits .How can I avoid such issues? 在 Github 上更改拉取请求的基本分支时将删除哪些提交? - What commits will be removed when changing the base branch of a pull request on Github? 如果主分支有新提交,则无法在 Github 上更新拉取请求 - Unable to update a Pull Request on Github if the main branch has new commits GitHub 拉取请求显示已经在目标分支中的提交 - GitHub pull request showing commits that are already in target branch 在 github 的“合并拉取请求”操作之后,所有来自功能分支的提交和一个新的合并提交出现在开发分支上 - After github "merge pull request " action, all commits from the feature branch and a new merge commit appearing on the develop branch GitHub:是否可以在分支中创建具有选定(不是全部)提交的拉取请求并将其推入另一个分支? - GitHub: is it possible to create a pull request with selected (not all) commits in a branch and push it into another branch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM