Philippe Blayo
Philippe Blayo

Reputation: 11020

To color a limited number of lines in git log --oneline

When I pipe a git command to head to display only a few dozens of commits, the colors are lost:

git log --oneline | head -50

How to keep colors with a limited number of lines?

Upvotes: 1

Views: 477

Answers (3)

Bzil
Bzil

Reputation: 156

-(n) Show only the last n commits

Ref : https://git-scm.com/book/no-nb/v1/Grunnleggende-Git-Viewing-the-Commit-History

For exemple

git log -50 --oneline

Upvotes: 5

qräbnö
qräbnö

Reputation: 3031

How about using -50 as a parameter in your git log command?

It will show the newest 50 commits.

You can also write

  • --max-count=50
  • -n 50
  • -n50
  • -50

Upvotes: 3

mik01aj
mik01aj

Reputation: 12382

Git detects that you're piping to something, so it disables color, but you can force it to use color with --color:

git log --graph --oneline --all --decorate --color | head -50

Upvotes: 4

Related Questions