简体   繁体   中英

Git: how to revert the local edit before using git checkout <old-revision> <file>?

Say I have a file file.txt , I've committed some revisions and now I've edited it in my working copy, I didn't stage or commit these edits.

Then I use git checkout <an-old-revision> file.txt , the file.txt goes back to an old commit.
Now I regret my checkout, how do I bring my edits back?

With git you cannot get these local changes back because you never committed/added or stashed them. If you use an IDE like Eclipse or IntelliJ Idea then the first thing i would check is if you can recover your changes via the local history of the file. If you do not use an IDE then a backup would be helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM