husky icon indicating copy to clipboard operation
husky copied to clipboard

on aborting commit at preparing step husky deleted all the files it was supposed to add. I lost them completely

Open savinash47 opened this issue 7 years ago • 9 comments

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 # ...

savinash47 avatar Nov 15 '19 01:11 savinash47

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?

typicode avatar Nov 15 '19 03:11 typicode

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.

savinash47 avatar Nov 15 '19 05:11 savinash47

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.

savinash47 avatar Nov 15 '19 06:11 savinash47

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)

yuvalbl avatar Jun 18 '20 12:06 yuvalbl

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

juanlet avatar Oct 29 '20 21:10 juanlet

check your git stash.

savinash47 avatar Oct 29 '20 21:10 savinash47

@yuvalbl when did you lose your code then?

savinash47 avatar Oct 29 '20 21:10 savinash47

@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

Nwoye-Ezekiel avatar Apr 04 '22 10:04 Nwoye-Ezekiel

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.

mjlehrke avatar May 22 '22 06:05 mjlehrke