Reputation: 14929
I just made a mistake with my git repo (stupid programming while Dayquil'd). My steps were:
I need to resolve the merge from step 2, and then merge that result with the edits made in step 2. How can I do this?
Upvotes: 1
Views: 1119
Reputation: 185851
It sounds like your problem is simply that you overwrote the file and lost the merge conflict markers. The simplest way to deal with this is to use git mergetool
, which will use a GUI merge tool to deal with conflicts. This tool doesn't rely on the working copy version of the file with conflict markers, it actually re-merges the original files using the GUI tool of your choice. I highly recommend it as your normal go-to solution for merge conflicts.
If you really do want the file back with the conflict markers, you can just use git checkout -m -- file.txt
. This will re-create the merge conflict version of the file. Note that any changes you made in steps 3 and 4 will be lost.
If you want to save the local changes you made, you can use git diff :2:file.txt file.txt
to view a diff between your pre-merge copy of file.txt and the copy you saved to disk. You can pipe this to a file in order to use later to re-create your changes after you solve the merge, or even use git apply
with the file to apply it as a patch (as long as it doesn't touch any hunks that the merge changed).
Upvotes: 3