I need to have format like:
git log --decorate --graph --oneline --date-order
but I need it also:
I tried:
git log --decorate --graph --oneline --date-order \ --date=short --pretty=format:"%h %ad %s"
but it's harder to read (no colors) and does not include branches/tags
The closest simple solution is(thanks VonC):
git log --graph --pretty=format:'%C(yellow)%h%Creset \ -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' \ --abbrev-commit --date=short
The colors are merely meant to help you view the lines as distinct from other lines. To answer question #1, they are assigned not pseudo-randomly, but rather sequentially, each time git log --graph picks a new "column number".
git log by default shows the entire ancestry in order by birthdate (where timestamp weirdities don't make that contradict ancestry). Try it with git log --oneline --graph --decorate --first-parent . ^ or ^1 means the first parent.
You can try:
alias.lgb=log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=short --branches
It has different color, but you can change them easily.
for instance:
git log --graph --pretty=format:'%Cred%h -%d %s (%cr) <%an>%Creset' --abbrev-commit --date=short --branches
Well, "impossible" means that there is no easy way and I'll have to do it myself. I worried too much that I always make things the hard way, when there is actually easier way.
Here is a bash+php script. I tried to make it with sed, but I failed.
I named this script git-gd and put it in a bin directory that's in path /usr/local/bin/
and I use it with git: git gd
or git gd <options>
#!/bin/bash GIT="/usr/local/bin/git" PHP="/bin/php" GIT_DATES="$GIT log --date=short --abbrev-commit --pretty=format:%C(yellow)%h_%C(green)[%ad]%Creset --branches --color=always $*" #if you have have alias g GIT_GRAPH="$GIT g --color=always" #or #GIT_GRAPH="$GIT log --decorate --graph --oneline --date-order --color=always" PHP_SCRIPT=' $exps = explode("\n", $_SERVER["argv"][1]); $lines = file("php://stdin"); $s = array(); $r=$s; foreach($exps as $exp){ $exp = trim($exp); list($commit,)=explode("_", $exp); $s[] = $commit; $r[] = str_replace("_", " ", $exp); } foreach($lines as $line){ $line = str_replace($s, $r, $line); echo $line ; } ' DATES=`$GIT_DATES` $GIT_GRAPH $* |$PHP -r "$PHP_SCRIPT" -- "$DATES"
I'll wait a bit for simpler solution and I'll accept my own answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With