Harry Harry - 1 year ago 69
Git Question

How can I get second or third commit id?

I want to get specific git id in history.
I know how to do it only for the latest one:

$ git log -n 1 --format=%H

But how can I get the
th most recent commit?

Answer Source

Get i'th most recent commit using tail:

git log -n i --format=%H|tail -n 1

Example (get 10th commit)

git log -n 10 --format=%H|tail -n 1

A git-only way:

git log --skip (i-1) -n 1 --format=%H

Example (get 10th commit)

git log --skip 9 -n 1 --format=%H

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download