on aborting commit at preparing step husky deleted all the files it was supposed to add. I lost them completely
Before creating an issue, see troubleshoot section in the README and verify that you're using Git >= 2.13.0.
Please provide your OS, terminal and the following commands output:
$ HUSKY_DEBUG=1 npm install husky --save-dev
$ HUSKY_DEBUG=1 git commit # ...
Hi @savinash47,
Sorry that you lost files. That said, husky only runs commands associated to hooks and have no knowledge of files that are going to be added. Which hooks/commands were defined in .huskyrc/package.json?
Sorry my bad. I think it is because of lint staged. I am using husky with lint-staged (prettier eslint). I aborted it on step one but lint-staged somehow removed the untracked staged files. Closing the issue.
found the issue. It was because of lint-staged because i aborted it stashed the changes but didn't let me know about it on abort. Did some reading about it and found that it does some stashing and found it on stash.
Thank you, @savinash47 ! I thought my last hours of work lost completely, and was happy to find them on stash :)
Any idea why it is happening, or in which cases? (I did not aboard my lint-staged process)
Same here,. Not only Husky deleted the content of the files I changed, but also the content of ALL files. The files are still there but empty
check your git stash.
@yuvalbl when did you lose your code then?
@savinash47 I had a similar issue as well and I was so sad that all my work had been permanently deleted but thanks to you, I was able to retrieve them using: git stash apply
found the issue. It was because of lint-staged because i aborted it stashed the changes but didn't let me know about it on abort. Did some reading about it and found that it does some stashing and found it on stash.
Just had the same thing happen to me, except lint-staged failed in the middle of the run. Wild that lint-staged does not mention the changes are stashed and just gives the message that the working directory was reverted. I thought it had wiped all of my changes.