3

I am building a theme for NodeBB and the theme lives inside the node_modules directory. Pulling in from master last night I have a new .gitignore my file had ignore all node_modules except for my theme, well since this is a new .gitignore it didn't track my changes.

Then I made changes to my theme without it being tracked. I decided to merge with my repo, after some conflicts took a step back then did npm prune now this pruned my theme, I spent the last hour making changes that I am not sure I can get back.

My question is since the folder was not being tracked is it possible to undo the npm prune and recover the theme within node_modules?

Michael Joseph Aubry
  • 12,282
  • 16
  • 70
  • 135
  • Sorry, but I don't think so. If git was not tracking the files at all, you can't get them back (unless you used to have them in the repo, but still, the latest changes that you lost would not be part of it). – Léo Lam Nov 14 '15 at 20:01

1 Answers1

1

Sadly, I think you won't be able to get your files back.

If you added the files or the directories to .gitignore, then git wasn't tracking them. So you cannot get them back with git, unless you used to have them in the repo, but even if you did, the latest changes that you lost would not be part of the repo. Sorry for the negative answer.

However, all is probably not lost right now. If you immediately unmounted the file system or remounted it read-only as soon as you realised you deleted your theme, you could always try a file recovery tool such as photorec.

Léo Lam
  • 3,870
  • 4
  • 34
  • 44
  • 1
    Cool man, this is good to know. Thankfully they were minor CSS changes and I was able to remember most changes I made, but it's still definitely a pain having to repeat the exact changes you made 1 hour ago lol. At least it was much faster the second time around. – Michael Joseph Aubry Nov 14 '15 at 20:20
  • Glad to hear you didn't lose your changes completely. I once did a similar mistake, `git clean`ing files. And of course, the files I mistakenly deleted were not (yet) tracked by git. – Léo Lam Nov 14 '15 at 21:14
  • Well afterwards I found I did a force push and lost a plugin I was working on, but thankfully I found http://stackoverflow.com/questions/3973994/how-can-i-recover-from-an-erronous-git-push-f-origin-master `git reflog show remotes/origin/master` let me get the plugin back :) All is well now, I hoped for a productive day but unfortunately 5 hours later and I am pretty much where I started last night lol. – Michael Joseph Aubry Nov 14 '15 at 22:58