In git, how do you revert a file back to 3 commits ago?
-
20-12-2019 - |
Question
I changed an image file in git and it was 2 commits ago. How do I go back to 2 previous commits ago?
What is the easiest method of doing this file revert via the command line with the least amount of commands required?
Solution
Just check out the old version of that file:
git checkout HEAD~2 -- path/to/file
Or more explicit:
git checkout commit-id -- path/to/file
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow