Find a commit which has the HEAD

Answered

I retrieve a list of commits in a branch beforehand and need to make decisions when I checkout revisions (previous or next), so I want to find a commit the working copy of the project is currently referring to. Initially HEAD is in a known position, but later I will need to find a detached HEAD as well. 

The idea is I have two buttons that switch between commits (checkout revisions) back and forward in a pre-filled list of commits. Would love some tips on how do I go about that.

Thank you!

0
2 comments

> I want to find a commit the working copy of the project is currently referring to. Initially HEAD is in a known position, but later I will need to find a detached HEAD as well

In Git the HEAD is pointing to the commit which the project is currently referring to, no matter whether the repository in on branch, or on a detached HEAD. So it should be fine to always refer to the HEAD.

0
Avatar
Permanently deleted user

Thank you, Kirill!

0

Please sign in to leave a comment.