screwgoth
screwgoth

Reputation: 131

How to revert "git rm" of an untracked file

I'm facing a situation where I have accidentally done a git rm foo.c before committing it even once. So, it was completely untracked by git and yet the file was physically deleted. I have already tried git reset --hard and git checkout ., but they both don't seem to work.

Any suggestions before I restart the arduous task of rewriting that file?

Upvotes: 2

Views: 1630

Answers (2)

Ilya Kozhevnikov
Ilya Kozhevnikov

Reputation: 10432

May be try gitjk or recuva first before rewriting it.

Upvotes: 1

tjati
tjati

Reputation: 6079

If a file is not tracked, git can't help you. That's the only requirement git has: you need to track files. It's not git's mission to watch ("track") untracked files.

You need to recover your file with some other method.

Upvotes: 3

Related Questions