I mistakenly deleted a folder and committed the change. How can I recover the folder?
Asked
Active
Viewed 515 times
0
-
2Welcome to Stack Overflow @Pedro Mesquita - Bem vindo. Check here: https://stackoverflow.com/questions/30875205/restore-a-deleted-folder-in-a-git-repo - possible duplicate – José Fonte May 30 '17 at 21:10
3 Answers
1
git checkout ****** folder
where ****** is a commit or a branch. This command put in current working directory the folder at the signed commit/branch.
For example, if you are in a particular branch you can run
git checkout master foo/bar
this will put in your current working directory the foo/bar
that was present in master branch.

sensorario
- 20,262
- 30
- 97
- 159
0
Try to undo your last commit in git. This stackoverflow question should be what you're looking for

rma
- 1,853
- 1
- 22
- 42
-
Thank you very much. Had to find the commit and merge the HEAD because it was detached. From there i had to add the folder again and managed to recover it. – Pedro Mesquita May 31 '17 at 01:28
-
0
Just check out the commit before you deleted the folder if you want to temporarily bring it back. If you want to permanently bring it back, you should probably revert your "bad" commit and then go from there.

Joe Phillips
- 49,743
- 32
- 103
- 159