问题
I branched from master and created a branch called extra_work. Then I made lots of changes to master which included removing some files as well. Later now when I tried to merge the branch 'extra_work' into the master, it is not merging it entirely. 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. How do I merge these two branches so that all the extra files/work from my 'extra_work' branch merges into master. Thanks
回答1:
Rebase your extra_work
branch against master
. This will rewind your extra_work
branch to the state when you branched, and apply the commits from master
to extra_work
. It will then replay all the commits from extra_work
back onto itself. If you inspect git log
after that you will see the commits from master
further back in the history of the branch. You should then be able to merge to master
with no problems.
git rebase master
回答2:
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
. 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
来源:https://stackoverflow.com/questions/4829964/git-merge-not-merging-all-changes-from-remote-branch