Noz.i.kor
Noz.i.kor

Reputation: 3747

What git commit am I on

To track down a commit that introduced a bug somewhere, I checked out an old commit using

git checkout <sha1 hash> .

Now is there a way to know what commit you are on? There should be a git command to tell me that I am not on the most recent commit.

I tried

git log
git log -1 
git status
git show

but all of these show me the most recent commit. (git status shows all files after this old commit as modified files, but still it doesnt tell me that I checked out an old commit)

Upvotes: 0

Views: 1824

Answers (2)

Noz.i.kor
Noz.i.kor

Reputation: 3747

Answering my own question; removing the dot at the end of the checkout command

git checkout <SHA1 HASH> .

now tells me that the HEAD is detached.

Upvotes: 0

drewag
drewag

Reputation: 94753

git status will work. If you are not on the latest commit (nor on any other branch), git status will show something like "HEAD detached at 4791138".

Your problem is that you are adding a "." after the hash. That is telling git to checkout all files at that commit, instead of moving HEAD to the old commit.

Try just doing git checkout <sha1 hash> (no ".")

Upvotes: 1

Related Questions