Reputation: 342
I had git merge conflicts after deleting some files (on OSX) and ran:
git mergetool
After running through most of the conflicts, I accidentally deleted a local file I meant to keep:
Deleted merge conflict for 'app/xxxapp/xxxapp/AppDelegate.swift':
{local}: created file
{remote}: deleted
Use (c)reated or (d)eleted file, or (a)bort? d
Is there any way to recover the file?
Upvotes: 1
Views: 301
Reputation: 488463
Yes: after git mergetool
finishes (or in another window), run:
git checkout --ours app/xxxapp/xxxapp/AppDelegate.swift
git add app/xxxapp/xxxapp/AppDelegate.swift
The first command extracts the HEAD version of the file into the work-tree, and the second tells Git that this is the correct resolution (vs what you already told Git through git mergetool
: that the correct resolution was to discard the file).
You can also or instead use:
git checkout HEAD app/xxxapp/xxxapp/AppDelegate.swift
The latter has the advantage of marking the item resolved all in one command.
Upvotes: 1