简体   繁体   中英

Git Merge - Not merging all changes from remote branch

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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