Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log first 10 in git

Tags:

git

logging

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?

like image 917
yohan zhou Avatar asked Apr 27 '12 05:04

yohan zhou


People also ask

How do I limit a git log?

The most basic filtering option for git log is to limit the number of commits that are displayed. When you're only interested in the last few commits, this saves you the trouble of viewing all the commits in a page. You can limit git log 's output by including the - option.

What is the order of git log?

By default, with no arguments, git log lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first. As you can see, this command lists each commit with its SHA-1 checksum, the author's name and email, the date written, and the commit message.

What is git log -- Oneline?

Git Log OnelineThe oneline option is used to display the output as one commit per line. It also shows the output in brief like the first seven characters of the commit SHA and the commit message. It will be used as follows: $ git log --oneline.

What is git log command?

The git log command displays all of the commits in a repository's history. By default, the command displays each commit's: Secure Hash Algorithm (SHA) author. date.


2 Answers

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.
like image 60
kostix Avatar answered Oct 08 '22 16:10

kostix


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

git log  --pretty=oneline | tail -n 10 
like image 35
CharlesB Avatar answered Oct 08 '22 15:10

CharlesB