New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lost new untracked files #779
Comments
This definitely shouldn't happen. What's your git version? I see this is a monorepo, are you running lint-staged in a subdirectory or the main git repo root directory? Can you run using the The untracked files are hidden into the main backup stash, using Can you add an untracked file, and then run these commands: git stash save --include-untracked --keep-index
git stash pop If the untracked file is back, then it might not be a direct Git issue but something else. |
Thanks for the fast reply git version 2.21.0 (Apple Git-122) Yes, it's a monorepo and lint-staged is set up on the root |
Maybe you know some way to restore those files? A little bit afraid to do something with 'stash' is there is a chance to restore them. Lost work results from few days |
The command |
I'm also experiencing this. I've been trying to figure out why this is happening, and as far as I could understand, I think this is happening because when executing the (This is undesired behaviour is not happening in version |
After upgrading to version 10, I'm experiencing this as well. I lost my entirely untracked files. Unfortunately, VSCode keeps the files open so that I can save it again. But the static files I made are all gone.
Hi @kratos-42 , when I run that command, it returns I'm reverting back to use version 9. |
@jefrydco when I said to run that command I was proposing a solution to solve the bug, and not providing a way to get your files back. I'm sorry if I was not clear. |
I’m terribly sorry about this bug, and I’ve no idea where it comes from since it hasn’t been an issue during development. I’ll try to get this fixed ASAP. The first thing to do is throw errors when restoring untracked files fails, so the process fails and everything gets restored. Are there a lot of untracked files when this happens? The tests only use a single untracked file so maybe it’s maybe it’s related to the size of the diff (speculating based on the first report’s git status). |
I don't think there is a failure in restoring to be thrown. I think the problem is in the response from the It happens no matter if there's just one or many untracked files. |
The untracked files are restored separately from the This happens after running tasks and applying back the unstaged diff. The untracked files are taken straight from the third commit. |
@kratos-42 Oke, got it. My stash files aren't empty anyway.
I think the @kratos-42 opinion was right. It will apply/restore are just for the files that already exist. My unstaged files are mostly just created and there was a lot of them. |
The untracked diff might not have taken binary files into acocunt, because the |
I don't know what kind of binary files you mean, but my untracked files were consists of markdown, images and video files. The files that already exist were unfortunately opened in VS Code so I can save it again. But the images and video were all gone. |
I tried using the |
I'm afraid the error may have been caused by the combination of the missing I've opened #780 for this issue. |
Sorry man, but I don't think that is enough to solve the problem. Using |
@kratos-42 If you're able to debug further, are the binary files in the diff, or missing? I'll try this:
EDIT: This works at least when manually running the commands. The major difference is that I'm piping the output of the diff to |
The binary files are in the diff. |
@kratos-42 In the PR, if the However, it would be nice to figure out why it doesn't apply. |
Tried it but haven't found any info about lost files in commits here ( |
Well, a possibly an error with
A way to do this could be redirecting the output to a file and read from there, something like: await execa(
'git',
[
'show',
...GIT_DIFF_ARGS,
'--format=%b',
`${backupStash}^3`
],
{ all: true, cwd: process.cwd() }
).stdout.pipe(fs.createWriteStream('stdout.patch'));
await this.execGit([...GIT_APPLY_ARGS, 'stdout.patch']); |
@MikeYermolayev Maybe read this if it contains something that can help: @kratos-42 Thanks for the suggestion. Since we create two diffs (unstaged, untracked), I'd then probably redirect both of those to files. The files should probably be deleted right after applying. |
Thanks a lot! Your link helped and I was able to find my files pretty easily by using |
@kratos-42 based on your suggestion, I pushed new commits to #780 that, instead of using variables inside the Node.js process, saves the unstaged and untracked diffs temporarily inside the Can you perhaps test this yourself? |
@iiroj Everything is perfectly working 👌 |
@kratos-42 Very good! We'll assume that one contributing factor was indeed the very large size of the diff. |
If you were affected by this bug and lost untracked files, you can try to restore them with: ```sh gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' ) ``` Please see #779 and https://stackoverflow.com/questions/89332/how-to-recover-a-dropped-stash-in-git for more info
🎉 This issue has been resolved in version 10.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
FYI I also experienced a similar issue to this (not sure if it's the same thing as this is marked as fixed) with lint-staged 10.5.3, though I was luckily able to retrieve my files utilizing the tip from @MikeYermolayev above. |
lint-staged 11.1.2 just lost an untracked file whilst running prettier and eslint (failed) MacOS: 11.2 |
Same here. I keep losing all the files including the existing one that have been modified. I keep those files open in VScode and then saving them again to restore. However this happens only in one repo and other repos are working fine. Everything is same like the version/OS/folder structure etc except that any changes made in the file in this repo are getting deleted. However it keeps some of the files, for e.g it keeps pacakge.json file but all my typescript files are keep getting deleted. As you can see at the end it says 1 deletion where in fact I have not deleted any files. git version 2.32.0 package.json
Here is the debug log
|
Hello there.
For the second time I experience very strange issue which leads to total lose of unstaged files :((((
I had some changes and few new files. I did:
After running all the hooks I can see that all my new files are lost.
Thanks in advance for any help
Here is log from console:
Environment
lint-staged
: 10.0.0The text was updated successfully, but these errors were encountered: