Search code examples
gitlogginggit-log

How to log first 10 commits 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

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

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