How do you usually restore a deleted file? #2166
Replies: 2 comments 1 reply
-
Turns out one could use the From the help
I guess I can get rid of step 2, and change 5 to: |
Beta Was this translation helpful? Give feedback.
1 reply
-
Alternatively, if you're already editing the file you want to restore in the history (e.g., via |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here is what I did, today, but was curious to see if there were a better way of doing it.
Find the commit which deleted the file (either via
:Gclog ...
, or with:G
), and open it (<CR>
,gO
,O
, you name it)Copy the commit id with
y<C-G>
Find the chunck where the file got deleted, and then open the deleted file by pressing
<CR>
on its path:Ge
to edit the same file in work tree:Gread
incantation (i.e.,:Gread <C-R>0^:%
) to finally load the content of the deleted file<C-R>0
loads the commit ID from step 3^
is to select the ancestor:%
is to load the content of the file (without it, it would dump the commit message into the buffer)Now, I can live with this: it's not like I am spending my day restoring files; but I was wondering if there wasn't a simpler way of doing this; maybe something that did not require step 2?
Beta Was this translation helpful? Give feedback.
All reactions