Git merging a file, actually trying to re-do the merge for one file?

Since you haven't committed it yet, you can just check out the unmerged version of the file.

Since you haven't committed it yet, you can just check out the unmerged version of the file: git checkout --merge path/to/file Then you can re-resolve the conflict as you like. (-m is a synonym for --merge. ).

– Jefromi yesterday yes, the merge is not committed. This is a normal modify/modify conflict, but the number of conflicts is high. – Gaurav Sinha yesterday 1 Hm.

I've used this plenty, and just retested it just in case.It worked fine. The three versions that are referred to are the common ancestor, and the "ours" and "theirs" branches. I'm not sure what could have gone wrong for you.(Double-check, just in case - maybe clone the repo and redo the merge there, and make sure that this file truly does have a modify/modify conflict, with a common ancestor.

) – Jefromi yesterday yes, I think something went wrong after I tried a lot of things in this directory, un-staged / staged the file a couple of times. I am taking a backup of the entire source and will re-do the merge for the file which didn't compile and finally copy the files that did compile to this directory. Thank you – Gaurav Sinha yesterday.

You can run git merge-file, which does a 3-way merge. If HEAD is the merge you just did, something like the following should work: git cat-file blob HEAD^:fileB > fileB # revert fileB to its pre-merge condition git cat-file blob $(git merge-base HEAD^ HEAD^2):fileB > fileB. Base # write the base version to fileB.

Base git cat-file blob HEAD^2:fileB > fileB. Other # write the other version of fileB git merge-file fileB fileB. Base fileB.

Other This will re-run the merge and write the merge results (including conflicts) back into fileB (at which point you can delete fileB. Base and fileB. Other).

Edit: If you haven't actually ran git add fileB yet (e.g. If git status shows the merge conflict), and if you have the git-merge-one-file script on your disk (in my case it's sitting at /usr/libexec/git-core/git-merge-one-file), then you can run git merge-index /path/to/git-merge-one-file fileB and it will re-merge that file for you.

Sounds like the merge resulted in the solution not ending up in a good state. Just edit the files you need to change so everything compiles and all your tests pass. If you want certain files to be pulled off of a state just before the merge, git checkout origin/branch_you_want -- fileA fileB Now just amend your merge commit: git add -A git commit --amend -C HEAD This will reuse the same message.

You should see your merge commit in a good state now. UPDATE: WARNING! When doing merges and using --amend, you may have recorded a conflict resolution you did not intend!

See rerere: progit.org/2010/03/08/rerere.html.

I haven't committed it yet. Also, the file had lots of merge conflicts, which are difficult to resolve manually without git putting in HEADs and ==== to quickly get to it. If I can get the merge to run for only this file, then this would make my life easier.

– Gaurav Sinha 2 days ago 1 I see the discussion has helped you out. I just wanted to add this discraimer to my answer. Watch what you record for rerere when monkeying with merges after the fact :) – Adam Dymitruk yesterday thanks, I wish I knew this command before I started.. – Gaurav Sinha yesterday.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions