Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override git log --format=oneline actual format?

Tags:

git

git-log

I have hard issue to rule out (which I do not want to bother you). To rule that issue out, I have found that on my failing system the command

$ git log --pretty=oneline

is equivalent to:

$ git log --pretty=format:%H%x20%s

This makes the long hash output. At the same time

$ git log --oneline

makes short hash output. Which is the desired output.

On the not failing system the --pretty=oneline format is equivalent to:

$ git log --pretty=format:%h%x20%s

This makes short hash output.

I have been looking how to override the oneline configuration in git and it seems that the oneline is hard coded, i.e. I can not change the format with:

$ git config --global pretty.oneline %h%x20%s

I can make different pretty format

$ git config --global pretty.myline %h%x20%s

and it will show nicely the short hash with

$ git log --pretty=myline

The trouble is that I want to rule out the issue dependence to exact log command hash printout length. I can not use different command like

$ git log --pretty=format:%h%x20%s

Is there a way to override the pretty formats like oneline?

like image 232
Peeter Vois Avatar asked Oct 26 '25 10:10

Peeter Vois


1 Answers

Your overall analysis is correct, I get what you'd want to achieve, but built-in pretty formats are unfortunately fixed.

From the doc :

Note that an alias with the same name as a built-in format will be silently ignored.


However, the difference between these two git environments might be leveled in some other way. Maybe consider getting both installations to the same git version?

like image 54
Romain Valeri Avatar answered Oct 28 '25 23:10

Romain Valeri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!