12

Used a starter to scaffold a new project. Have never used that starter before but it has more than 1400 starts on Github.

Two days after.... so far so good. The created project structure used some tools I haven't used before, some are good, others are not so good, but anyway I am towards the first release of my codes. I have done countless 'npm run build', 'npm run test', 'npm run fix', etc., but.... my fault, I haven't committed once since starting the project, thinking I would commit when the next function is implemented, next test case passed.... after all, what could go wrong anyway?

Finally, one last test case passed, I think I will commit and run 'npm publish'.... but wait, had a glimpse of the scripts section in package.json, there's a command named 'all'. An voice came out of nowhere was talking to my subconscious mind, "all.... build, lint, prettier, test..... yeah you should run all... it's another build script, the worst you can get is just some harmless error messages.....", and my fingers typed 'npm run all'...

Time stopped for a few seconds, file structure in project explorer was shifting, files & folders were disappearing & appearing, what's happening... and I looked at the 'all' script closely for the first time....

WHAT THE HELL, WHO SHOULD PUT 'git reset --hard' IN A BUILD SCRIPT WITHOUT ANY PROMPT????!!!!!!!

MY PLAN WAS TO COMMIT AND GO TO SLEEP, IT'S 1AM NOW!!! WHERE CAN I RECOVER THE LOST FILES????

Comments
  • 2
    git reset hard in a build script is kinda weird, agree

    but think of the flipside: you tried to publish things that were not pushed to a git server. Don't do that.

    If you wanted to have a single initial commit, use git comment --amend
  • 5
    You learned two very difficult and important lessons today: the importance or backups, and not to trust other people's work.
  • 0
    Which IDE are you using? Some provide a local history that basically functions as a separate git storing all the changes.
  • 1
    I meant git commit --amend
Add Comment