What happens if I execute the following command when I have a local commit (i.e. a commit that I haven't pushed to the remote repository yet) that I want to revert back ?
git revert HEAD
I researched a lot and found out that -
- "git revert $id" is used to revert back changes made in a particular commit commit ID - $id, and
- the HEAD itself is nothing but a reference to a commit ID (of the latest commit).
But I'm unable to understand that in this scenario (when I have a local commit), the HEAD would point at my latest local commit, or the latest commit on the remote repository ?
Why I ask this?
- I tried "git pull" from my branch, but it wouldn't happen as I had some changes in my local.
- So, I executed "git commit", and then tried the "git pull".
- Now, "git pull" gave me errors (probably merge-conflicts : I happened to missed out on the details of the "errors"), so I decided to revert my commit, for which I executed "git revert HEAD".
- Now I'm confused that did this command (git revert HEAD) only revert my changes in the (local) commit I mentioned previously? or the last commit on the remote repository?