Kiril Shishkoski Kiril Shishkoski - 1 month ago 5x
Git Question

git source control checkout ignored

I'm developing an app in XCode and I'm using git repositories via terminal. All changes are committed and now I want to revert to my last commit, but, however, when I try to 'git checkout 10f3592' it says 'HEAD is now at 10f3592...' but in the XCode my source files are not changed. It seems like git is ignoring my command. What should I do? Does anyone has encountered a behavior like this before? I have only 1 branch btw. Any help is appreciated.


The command git checkout 10f3592 just checks out the branch in a detached head state at commit 10f3592. It does not actually change the state of your branch.

If you want to literally git revert commit 10f3592, then use git revert:

git revert 10f3592

This will instruct Git to make a new commit on the top of your branch which effectively undoes everything which commit 10f3592 did.

But sometimes it isn't so nice to have a revert commit in your history. One way to avoid this, if you haven't yet pushed your local branch, and no one else has yet seen commit 10f3592, is to nuke that commit via:

git reset --hard HEAD~1