Find a commit which has the HEAD
已回答
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!
请先登录再写评论。
> 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.
Thank you, Kirill!