Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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?

like image 688
bmargulies Avatar asked Jul 09 '15 16:07

bmargulies


1 Answers

I would suggest to:

git pull --rebase origin develop

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

like image 113
hek2mgl Avatar answered Sep 20 '22 19:09

hek2mgl