1

There are two branches in my project: b1, b2,And someone made some changes in b1, and I try to merge b1 into b2 using git merge b2, I found there are so many conflicts, so I give up all the revision, and run git push in b2, so there is the commit record of merging b1, but the changes don't exist in b2. And then, there are some other commits in b2, now I want to merge b1, it comes all ready up to date. So how to merge the changes in b1 now ?

laoqiren
  • 2,375
  • 4
  • 15
  • 26
  • `so I give up all the revision` ... you completely lost me here, and I don't understand what you did from this point onward. If you got merge conflicts, then you should try to resolve them, or else it means you can't merge. Even if you tried another method, e.g. rebasing, you probably would still have gotten conflicts. – Tim Biegeleisen Aug 08 '18 at 01:50
  • @TimBiegeleisen `I give up` means at that time I dare not deal with the conflicts so I give up Temporarily, but now I want to merge it, it shows `all ready up to date` because there is merging commits record in `b2`. – laoqiren Aug 08 '18 at 01:53
  • You can't just "give up" like nothing happened, you have to stop/undo the merge you started. If you _didn't_ do that, then you may expect problems. – Tim Biegeleisen Aug 08 '18 at 01:54
  • @TimBiegeleisen Yes, the problem comes here, so is there some way to resolve this situation? – laoqiren Aug 08 '18 at 01:55
  • What does `git status` show you from your branch `b1`? We can start here, and then try to resolve the problems. – Tim Biegeleisen Aug 08 '18 at 01:56
  • @TimBiegeleisen It shows `Your branch is up to date with 'origin/b1` – laoqiren Aug 08 '18 at 02:01
  • Working directory clean? Stage clean? – Tim Biegeleisen Aug 08 '18 at 02:01
  • @TimBiegeleisen Yes, all clean. I use another branch like `b3` to merge `b1` , all performs well. – laoqiren Aug 08 '18 at 02:03
  • If you really need to bring branch `b2` into branch `b1`, then there may be no avoiding the merge conflicts. – Tim Biegeleisen Aug 08 '18 at 02:16

1 Answers1

1

And then, there are some other commits in b2, now I want to merge b1, it comes all ready up to date. So how to merge the changes in b1 now?

One suggestion would be to use git cherry-pick in order to cherry-pick only the relevant commits from b2 into b1.

Be aware though that might be problematic if, later down the road, b2 will need to be fully merged into b1. Because of duplicate commits.
And you need to be sure the commits you are cherry-picking to b1 have no functional dependencies with other (not-merged) commits from b2.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 2
    Sorry for the downvotes: I was editing your answer (to show you what an actual answer should look like) while other were just downvoting. I hope that will give you an idea of how to answer on Stack Overflow. Meaning: no abbreviation, full complete sentences, links and references. Welcome to Stack Overflow! – VonC Jan 04 '19 at 07:46