Question

I'll attempt to be as clear as I can, though I'm not sure how I got into this situation and all attempts to re-create it have failed.

I've been working on a branch, iss454, for several months now. During that time, I did make a couple attempts to keep it up-to-date by merging master into iss454 (this all went fine). I finally finished my changes and was ready to push them all into master. However, when I do this, I lose code from iss454 that I need, and I can't figure out why the merge is wiping those lines.

I've tried merging both ways, master to iss454 as well as iss454 into master (well, a clone of master). I've tried cherry picking last commit of iss454 into master. I've tried rebasing in both directions. I also tried doing a git merge -s ours master, which seemed to work, but then I was missing a ton of other changes. No matter what I've tried so far, not all of my changes from iss454 are making it over.

I've never had this trouble before, so I'm sure I did something along the way that threw me off, but as I said, I can't figure out what.

Any thoughts on how to get my code merged in completely? I really don't want to have to manually fix this.

Was it helpful?

Solution

from your description is sounds like one of the commits in master has changes that are undoing your changes in iss454.

Your best bet is to try and track down that commit(s) I would look at the history of the file(s) in question via

git log --oneline --no-merges -- <path to your file>

or gitk <path to your file>

The look through those commits until you start to see how the changes are happening.

OTHER TIPS

Instead of merging right away, why not do some cleaning up first?

$ git checkout iss454 //or maybe a new branch just to be safe

Then squash the commits into one meaningful one:

$ git rebase HEAD~5

^ You should choose a commit that is a common ancestor with master.

Change all the picks to squash except for the first line.

Then, update iss454's branch with progress made on master:

$ git rebase master

Finally merge iss454 into master:

$ git checkout master
$ git merge iss454
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top