I need to have format like:
git log --decorate --graph --oneline --date-order
but I need it also:
In non-ancient versions of git you can configure git log
to enable decorations thusly:
git config --global log.decorate full
In addition in your git config you can add two lines like this:
[format]
pretty = %Cblue%h%Creset %Cgreen[%ar]%Creset (%an) %s
This just means you can type git log and it will always be formatted.
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
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