4 ms·
I never managed to find how do I revert changes in a file with git I'm not sure why anyone should think this hard to do. When you do "git status" it even tells
by nessus42 15y ago
I never managed to find how do I revert changes in a file with git
I'm not sure why anyone should think this hard to do. When you do "git status" it even tells you how to do it:
git checkout -- myFile
That will replace any changes to myFile that haven't been checked in yet with the most recent version that was checked in. If you want to go back to an older version, you can do
git checkout a2791d14adf3 myFile
where that funky number is any unique prefix of the commit identifier that "git log" shows you.
Well, that's if you haven't "staged" your changes. If you've staged the changes, you have to "reset" the staging for the file first. I admit that this staging thing is a bit confusing, so I rarely stage anything. There's no reason that you need ever "stage" anything in Git if you don't want to, so I'm not sure that that bit of extra complexity is worth worrying about.
- LoneWolf 15y agoThanks for that, spent a lot of time googling and never found that, maybe I didnt search properly, the solutions I remember finding always involved more than one command and were confusing.