merge - Git consistently merging one file incorrectly -
i'm having weird issue git's merge feature i've never seen before. merging changes branch master
, git seems consistently having trouble 1 particular file.
it's merging content seemingly random places. it's happened last few times file has been merged.
here changes made myfile.cs
on other branch (called somebranch
):
- service.updateuser(user); + service.updateuser(user, false); ... - user[] users = client.importpersonnel(a, b, c); + userimportresults results = client.importpersonnel(a, b, c); ... - response.write(jsonconvert.serializeobject(new { usercount = users.length })); + response.write(jsonconvert.serializeobject(new { added = results.numadded, updated = results.numupdated }));
just few lines of code.
so did this:
git merge somebranch master
most of merged without conflicts. few files have conflicts make sense. automerge changes made myfile.cs
strange. example, line
service.updateuser(user, false);
was stuck in random place in middle of master
version of myfile.cs
:
if (request["x"] != null) { calculatesomething(request["x"]); } <<<<<<< head if (request["y"] != null) { calculatesomething(request["y"]); } ======= try { client.updateuser(user, false); >>>>>>> qaqc-release if (request["z"] != null) { calculatesomething(request["z"]); }
i'm not sure how git determines how merge 2 files haven't seen before. , happens 1 file.
the place should merging change in , place it's doing little on 100 lines apart. however, file 5000 lines long relatively speaking it's not far off still it's odd.
any ideas why happening or can it? often-touched file it's going merged. it's never been issue in last year or of development i'm not sure changed great address it.
two things check:
- since oft-merged file, perhaps there incorrect merge performed , backed out in past, that's been recorded
git rerere
. maybe in meta-data there if have enabled? - your code formatting may throwing things off. if file has many places can match beginning of patch, 1 that's adding new lines, see getting confused if doesn't consider enough context. maybe there's flag
git merge
tell @ broader range of context default, prevent mistaken matches?
Comments
Post a Comment