log first 10 in git

后端 未结 9 1993
刺人心
刺人心 2021-01-30 12:27

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
9条回答
  •  不知归路
    2021-01-30 13:03

    In case someone wants more than just git one-line log:

    git log --reverse | awk 'NR>1 {print last} {last=$0}; /^commit/ && ++c==11{exit}'
    

    where the 11 at the end should be set to 1 more than the number of commits you want.

    As here points out git log --reverse -n 10 doesn't work as you need it to. (I suppose it would need to be non-commutative to give you the ability to chose the first 10 commits in reverse order or the last 10 commits

提交回复
热议问题