简体   繁体   English

Git Merge - 不合并远程分支的所有更改

[英]Git Merge - Not merging all changes from remote branch

I branched from master and created a branch called extra_work. 我从master分支并创建了一个名为extra_work的分支。 Then I made lots of changes to master which included removing some files as well. 然后我对master进行了很多更改,其中包括删除一些文件。 Later now when I tried to merge the branch 'extra_work' into the master, it is not merging it entirely. 后来,当我试图将分支'extra_work'合并到master中时,它并没有完全合并它。 It is not adding the files that I removed in master, basically all the work that I had undone, now I want it back into my master. 它没有添加我在master中删除的文件,基本上所有我已经撤消的工作,现在我想要它回到我的主人。 How do I merge these two branches so that all the extra files/work from my 'extra_work' branch merges into master. 如何合并这两个分支,以便我的'extra_work'分支中的所有额外文件/工作合并为主。 Thanks 谢谢

Rebase your extra_work branch against master . 将您的extra_work分支重新对准master This will rewind your extra_work branch to the state when you branched, and apply the commits from master to extra_work . 这会将您的extra_work分支回extra_work分支时的状态,并将提交从master提交到extra_work It will then replay all the commits from extra_work back onto itself. 然后它会将extra_work所有提交extra_work放回自身。 If you inspect git log after that you will see the commits from master further back in the history of the branch. 如果你之后检查git log ,你会在分支的历史记录中进一步看到master的提交。 You should then be able to merge to master with no problems. 然后你应该能够毫无问题地合并到master

git rebase master

I ran into the same problem very recently while doing major refactoring. 在进行重大重构时,我最近遇到了同样的问题。 I solved the problem by doing git rebase , from master rebasing onto extra-work . 我通过执行git rebase解决了这个问题,从master变为extra-work I don't fully understand this whole thing, but the merge went terribly (like you experienced) but rebasing in this particular direction was very easy. 我并不完全理解这一切,但是合并得非常糟糕(就像你经历过的那样),但在这个特定方向上的变革非常容易。 See the git book on rebasing: http://book.git-scm.com/4_rebasing.html 请参阅有关变基的git书: http//book.git-scm.com/4_rebasing.html

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

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