[英]How to merge and push a local branch in git
Hi I am in difficulty with this scenarios: I have two local branch: develop and branch1 . 嗨,我在这种情况下遇到了麻烦:我有两个本地分支: develop和branch1 。 On remote I have develop branch only. 在远程,我只有开发分支。
The steps that i followed: 我遵循的步骤:
I need to create, and push all the modification of branch1 on remote. 我需要创建并在远程上推送分支1的所有修改。 After doing it I am costrained to go to github and make a pull request from my "branch1" remote branch to the develop remote branch. 完成此操作后,我非常费心去github并从我的“ branch1”远程分支向开发远程分支发出拉取请求。
Which are the steps that I need to do in case of conflicts? 如果发生冲突,我需要执行哪些步骤? I try to read a lot but the major part are merging in local and push on develop ( or master ) but my scenario is different cause i need to push on remote branch1 and from there to ask to review the code from a person and make a pull request. 我尝试阅读很多书,但是主要部分是在本地合并并进行开发(或掌握),但是我的情况是不同的,因为我需要继续进行远程branch1并从那里请求查看人的代码并制作一个拉取请求。 I need to avoid conflicts. 我需要避免冲突。
If I understand your question: 如果我了解您的问题:
Solution: 解:
Avoiding merge conflicts: 避免合并冲突:
There is no way to "avoid" merge conflicts in a workflow such as this one (or in any workflow, really). 在这种工作流中(或实际上在任何工作流中),都无法“避免”合并冲突。 The best you can do is to remind the peer reviewer that time-consuming merge conflicts are likely to occur unless they are reviewed and merged quickly. 您能做的最好的事情就是提醒同行审阅者,除非进行快速的审阅和合并,否则很可能会发生耗时的合并冲突。
Resolving merge conflicts: 解决合并冲突:
Most of the time, resolving the merge conflicts in this workflow is easy: 在大多数情况下,解决此工作流程中的合并冲突很容易:
git pull origin develop
git checkout branch1
git rebase develop
You really do need to know how to resolve merge conflicts, eg ref . 您确实确实需要知道如何解决合并冲突,例如ref 。
git push origin branch1 --force
(Force is required because the rebase operation rewrites the history.) (因为重新设置操作会重写历史记录,所以必须使用强制。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.