简体   繁体   English

如何对已合并 master 的分支进行变基?

[英]How to rebase a branch that has master merged into it?

I've run我跑过

git pull origin master 

in my dev-branch to merge master into it.在我的开发分支中将 master 合并到其中。 Now现在

git rebase -i origin/master

says there's merge conflicts that are not real.说存在不真实的合并冲突。 Incoming change is the 1st commit in the dev-branch (before the merge) and not current situation of the dev-branch.传入的更改是开发分支中的第一次提交(合并之前),而不是开发分支的当前情况。

Current situation of the dev-branch does not have any conflicts with master because master is just merged. dev-branch 的当前情况与master 没有任何冲突,因为master 刚刚合并。 The problem is that git thinks there is merge conflicts cause it compares master with old version of the dev-branch.问题是 git 认为存在合并冲突,因为它将 master 与旧版本的开发分支进行比较。 ie 1st commit which in this case is also the commit just before merging master into it.即第一次提交,在这种情况下也是将 master 合并到其中之前的提交。

So how this should be done?那么这应该怎么做呢?

IF you are facing merge conflicts then unless you resolve the conflicts you wont be able to run any git operations unless you resolve the conflicts.如果您面临合并冲突,那么除非您解决冲突,否则您将无法运行任何 git 操作,除非您解决冲突。 merge conflicts will occur if you try to change some files whose remote/master version also has some changes For example you have some changes in abhi.text file and in master branch also abhi.text also has some changes which are not pulled to your local And now you do git pull.....then you face this problem Solution-->>如果您尝试更改某些文件,其远程/主版本也有一些更改,则会发生合并冲突例如,您在 abhi.text 文件和 master 分支中也有一些更改,abhi.text 也有一些未拉到本地的更改现在你做 git pull.....然后你会遇到这个问题 解决方案-->>

Before git pull try之前git拉试试

git stash git 藏起来

to save the current new changed file and then do保存当前新更改的文件然后执行

git pull git拉

Now do —>>>现在做——>>>

git stash apply git 隐藏申请

to get the local changes which were stashed and then you may face CONFLICT (content): Merge conflict on specific file then go to Specific files do the changes like….you may get remote changes and local changes in unarranged manner..so just arrange it keep local changes after remote changes获取隐藏的本地更改,然后您可能会面临冲突(内容):合并特定文件上的冲突,然后 go 到特定文件进行更改,例如......您可能会以未安排的方式获得远程更改和本地更改..所以只需安排它在远程更改后保留本地更改

Now do—>>>现在做——>>>

git commit and push git 提交并推送

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM