Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - restore a deleted folder from previous commit

Tags:

git

I have a git repo on my local and I push it to BitBucket.

I have a deleted folder in my previous commit, which I now want to bring it back.

On my local machine, I do

git checkout COMMIT_ID path/to/deleted/folder

and I got

error: pathspec path/to/deleted/folder did not match any file(s) known to git.

Any advice?

like image 429
ericbae Avatar asked Sep 28 '13 06:09

ericbae


1 Answers

A cause of the error is likely to be that you're trying to checkout the directory from a revision it didn't exist in. Are you absolutely positive that in COMMIT_ID the directory existed?

By the way, the command should be

git checkout COMMIT_ID -- path/to/deleted/folder
like image 62
Gabriele Petronella Avatar answered Oct 21 '22 07:10

Gabriele Petronella