简体   繁体   中英

Git - restore a deleted folder from previous commit

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM