log first 10 in git

Two questions:

  1. How to show the first 10 commit in git from beginning to end. (no branch)
  2. How the specify the commit index and log it. (show the second or third)

I know that git use parent to link the commit, it's easy to log the commit from end to start. like: git log HEAD~10

But i need to query from the start to end, is it possible?


Solution 1:

git log -10

Would show 10 latest commits matching the revision spec (a missing spec means "all commits").

See manpage:

git help log

section Commit Limiting

-<number>, -n <number>, --max-count=<number>
    Limit the number of commits to output.

Solution 2:

Simply log everything with one line format and tail the output:

git log  --pretty=oneline | tail -n 10 

Solution 3:

Here my approach,

To get first 10 commits:

git log -n 10

-n is number

Additional To get next 10 commit skip first 10 :

git log --skip=10 -n 10