0

What I want to do is checkout a specific commit based on the commitId, but then I want to check out the commit that came just after the one I'm on. Is there any way to do this without using the commitId of the commit after the one I'm using? Or is there away to find out how far away from the current branch what I have is?

Basically I have the commitId of a revision that is X away from the head. I need to figure out how to get the commitId of the version that is X-1 away from the main or just find out what X is.

2 Answers 2

2
$ git name-rev --name-only HEAD

This will give you a useful name, such as master~6, or tags/mytag~2, that you can use to easily name the next commit (i.e. master~5 or tags/mytag~1).

2
  • Thanks! That's exactly what I wanted.
    – SSEMember
    Jun 27, 2012 at 15:51
  • Needed to wait 3 minutes but I went out to lunch haha. Accepted now.
    – SSEMember
    Jun 27, 2012 at 16:58
0

If you are checked out at a revision that is X commits behind a given branch (lets call it master, you could do this:

git log --pretty=oneline HEAD..master | wc -l

That should return the number of commits between you and the master branch

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.