Y
Y
Ytsu Ytsuevich2015-08-17 22:53:06
git
Ytsu Ytsuevich, 2015-08-17 22:53:06

Git. Accidentally deleted a local file, how to recover?

YES, I can download from the hub itself, but I want to know how to download it via the console. Is it possible at all?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2015-08-17
@kofon

If the condition is:

$ git status

On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

  deleted:    myfile

Then the file can be restored like this:
To restore a file from a specific commit or branch, you can do this:
git checkout abcde myfile # abcde — хеш коммита
# или
git checkout feature3 myfile # feature3 — имя ветки

M
maximw, 2015-08-17
@maximw

If no other necessary changes have been made, except for deleting the file.
git reset --hard

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question