I accidentially discard my changes on files in my local working tree via git checkout. The files aren’t staged at this time. Is it posible to “undo” this checkout?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I believe if a file is modified but not yet added (staged), it is purely "private".
Meaning, it cannot be restored by GIT if overwritten with the index or the HEAD version (unless you have a copy of your current work somewhere).
A "private" content is one only visible in your current directory, but not registered in any way in Git.
Note: As explained in other answers, you can recover your changes if you use an IDE (with local history) or have an open editor (Ctrl+Z).
I mentioned the VSCode Timeline view in Feb. 2020 with VSCode 1.44, as one way to recover changes with an IDE.