I have few commits on github that I want to change. So in my previous commit I've changed some file/folders and I need to revert changes only for some of them. What is the best solution to make it.
To move HEAD around in your own Git timeline, use the git checkout command. There are two ways to use the git checkout command. A common use is to restore a file from a previous commit, and you can also rewind your entire tape reel and go in an entirely different direction.
You can use git checkout:
git checkout HEAD~ -- file/to/revert
to stage a version of the file from the previous commit. Then just commit the changes and you're good to go! Of course, you can replace HEAD~
, which references the previous commit, with a hash of a commit, a further-back ancestor, or any "tree-ish" object you wish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With