Fun fact! If you added a file but never committed it you can still recover it with git fsck --lost-and-found. The changes were still added to the git object store, and by grepping through the dangling blobs you can find the object containing the changes you care about.
I mostly only use git at work and I guess I’ve never had the same work machine long enough to worry about this. It helps that each of our repos is fairly small. At least the ones I touch.
I’ve had juniors who didn’t believe this, so just to say it: If you know what you’re doing, practically any Git problem is recoverable.
The one major exception is if you delete your local changes before committing them.
All hail the mighty reflog!
Saviour of us all!
IntelliJ has local history for that case.
Fun fact! If you added a file but never committed it you can still recover it with
git fsck --lost-and-found. The changes were still added to the git object store, and by grepping through the dangling blobs you can find the object containing the changes you care about.Does deleting the repo off disk and redownloading from remote considered recovering? If so I’m a git expert.
Delete? Never.
mv git_repo git_repo.badI do this sometimes but then I forget about it and then node_modules in each repo fills my SSD.
I mostly only use git at work and I guess I’ve never had the same work machine long enough to worry about this. It helps that each of our repos is fairly small. At least the ones I touch.