0

So I deleted the folder contents and then git wrote that my entire folder was deleted. I accidentally pushed this into production and now my entire folder in production also got deleted. Is there anyway to get my folder contents back? I tried rolling back to the previous commit and that didn't do it.

kevinkt
  • 735
  • 12
  • 24
  • 1
    Rolling back will only restore stuff that was in version control before you removed the folder. It won't restore untracked files that may have been in production (user uploads, temporary files, etc.). In the future, to remove a folder's contents and keep the empty folder, put an empty `.gitignore` file in it. – ceejayoz Nov 01 '17 at 20:16
  • git doesn't keeps track of empty folders. I think that's why git didn't keep track of folder with deleted contents. @ceejayoz should be .gitkeep file. –  Nov 01 '17 at 20:29
  • 1
    @Eyorther The exact filename doesn't really matter. I like `.gitignore` as it may be useful there in the future. Hell, `.keep-me-or-everything-will-explode` would be fine. – ceejayoz Nov 01 '17 at 20:38
  • Awesome thanks guys! – kevinkt Nov 01 '17 at 20:54
  • 1
    Possible duplicate of [How can I add an empty directory to a Git repository?](https://stackoverflow.com/questions/115983/how-can-i-add-an-empty-directory-to-a-git-repository) – 3D1T0R Nov 01 '17 at 21:34

0 Answers0