bmargulies
bmargulies

Reputation: 100153

Is there a git merge strategy that copes with significant code movement?

In my branch, I moved 90% of the methods from one test class to another.

In main branch, someone added one method to the class I moved the code out of.

Then I went to do a downmerge; our convention is that you always merge from the main branch to your work branch before going the other way. I used:

git pull origin develop

The resulting merge created a file containing all the code that I had removed. I would have expected a 3-way merge to apply, which would have 'kept' my deletion and the other branch's addition. So I had to manually re-edit to get rid of all the classes that I'd deleted from the 'origin' class. Of course, I had to manually move the one new method; no objection there.

Is there an alternative git merge strategy which might have recognized what I meant?

Upvotes: 6

Views: 144

Answers (1)

hek2mgl
hek2mgl

Reputation: 158120

I would suggest to:

git pull --rebase origin develop

This puts your local commits on top of the remote commits.

Upvotes: 3

Related Questions