I
I
Ivan Trofimov2013-09-29 22:51:36
linux
Ivan Trofimov, 2013-09-29 22:51:36

How to take a step back? Accidentally made in the project folder rm -rf *

Overworked and the head does not understand at all. Accidentally executed rm -rf * in the console and deleted the week's work. Git is there but hasn't been committed for a long time. git st tells you which files were deleted, but I don't know how to get back all the deleted files. How can you step back and bring back everything that was deleted? Community, please help, otherwise it turns out very insulting.

Answer the question

In order to leave comments, you need to log in

13 answer(s)
B
barker, 2013-09-30
@barker

Tin, a week to write and not commit.

M
Maxim Dyachenko, 2013-09-30
@Mendel

Either they told you wrong at the LOR or you misunderstood.
git checkout - MyFile will roll back a specific file to the state of the last commit. Miracles do not happen and the git does not know what exactly you are too lazy to commit.
As they rightly said - either abandon the last commit and write again, from memory, or look for ways to restore data using the system tool or recovery utilities. But git has nothing to do with it.

M
max_mara, 2013-09-30
@max_mara

Eeee, then you don’t particularly torment the computer, so that you don’t accidentally write down anything superfluous from the top. If possible, then make a dd copy of the disk you are working on to a new medium. Then mount this image in read-only and there you already need to look for what programs you can restore the files you need.
You can then open the copy in any editor that can adequately read large files and search for the files you need. For example, if these are PHP files, then look for the occurrence of <?php (or whatever you have there) and restore them.

N
Nazar Mokrinsky, 2013-09-29
@nazarpc

Try
git reset HEAD
if it doesn't work, then try
git reset --hard HEAD

C
codecity, 2013-09-29
@codecity

Files can be restored (google). The main thing is not to write anything from above.

V
Vyacheslav Plisko, 2013-09-30
@AmdY

And you don’t use an IDE, they have a local history, everything goes perfectly from there, it saved me a couple of times from accidental deletion.

T
TyVik, 2013-09-30
@TyVik

photorec'om try to walk and pray.

A
akral, 2013-09-30
@akral

git checkout .rolls back the state of the given folder ( .) to the last commit.

M
max_mara, 2013-09-30
@max_mara

Missed…

N
Nikolai Antal, 2013-09-30
@hermit931

Just yesterday I restored the file with the Scalpel program (http://habrahabr.ru/post/55465/). I managed to restore a file 2 months ago, which I even forgot that I had deleted, I had to urgently restore it - the utility helped

P
pletinsky, 2013-10-02
@pletinsky

You can write a script that will go through the list and get them one by one.

S
sandrain, 2013-11-22
@sandrain

somehow local history in PHPStorm saved me

D
Dmitry, 2015-12-22
@Itachi261092

Normal IDEs always have Local History. In the editors from JetBrains and NetBeans for sure. Everything will be restored without problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question