lint-staged: Killing the lint script causes unstaged changes to be lost

Description

Using GitHub Desktop 1.0.13, I crafted a commit that had only some of the changed files staged, and also some hunk commits (i.e. just certain lines of a file staged, while other lines in the same file were not staged).

After clicking “commit”, the usual checking began. While the script was running (it always takes a few minutes for me), my machine froze due to lack of memory (I had too many things open at the same time). I hard-resetted the laptop by holding down the power button and then started again.

Actual behaviour: Opening the repo, I see that now the only changes left in the repository are the ones I had staged for that aborted commit. The unstaged changes are gone.

Expected behaviour: Even when the pre-commit script fails, no changes should be lost.

Steps to reproduce

Can’t provide right now

Debug Logs

Can’t provide right now

expand to view
COPY THE DEBUG LOGS HERE

Environment

  • OS: Ubuntu 18.04
  • Node.js: 8.10.0
  • lint-staged: 8.0.4

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 32 (2 by maintainers)

Most upvoted comments

For those experiencing this issue, your changes technically should be recoverable, as the tool persists the entire working tree before clearing unstaged changes. Unfortunately, nothing in the logs seems to tell you the hash for that tree for the purposes of recovery, so I guess you would have to check the folder timestamps in .git/objects.