简体   繁体   中英

Trying to merge two branches (one is very old, trying to pull master code) but there are conflicts in every file

the conflicts shouldn't even be conflicts... most of them are on the documentation I added, like tihs:

<<<<<<< HEAD
  # returns the max_sequence for this section
=======
>>>>>>> merged with other_branch_that_isnt_master

the command I did was git pull --rebase origin master

but when I just do git pull origin master , I still get tons of conflicts everywhere.

Why is it not merging appropriately? it's like git gave up on life.

How do I get git to actually merge my files?

I'm using git on Mac Lion.

It is likely that you committed to the wrong branch and had the branches diverge. This means that a rebase will no longer cleanly apply, creating conflicts.

One option is to perform a git merge and do the hard manual work of fixing the conflicts. Once the branches have merged, you should only need to do the work once.

Another option is to ignore all of the changes in the other copy of master and make your copy the authoritative one. This is not recommended, but it depends on your use case:

git fetch
git merge -s ours origin/master

Another option is to rewrite and fix the commit history as Dave has suggested. A summary follows:

  • Use gitk --all or git log --graph --all to visualise the history and see where the branches have diverged.
  • Use git reset --hard to rewind history to that commit
  • Do a git pull --rebase
  • git cherry-pick your commits back onto the rebased history, hopefully minimising conflicts.

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