Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My favorite one liner for a pretty and compact graph-like git log:

  git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
Add a global alias:

  git config --global alias.lg "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
Usage:

  git lg


Usage:

  git branches
Code for your ~/.gitconfig

  branches = branch -a --sort=-committerdate --format='\
  %(HEAD) \
  %(if)%(HEAD)%(then)\ 
  %(color:"#329664")%(objectname:short)%(color:reset) \
  %(color:"#222222")[%(committerdate:short)]%(color:reset) \
  %(color:green)%(refname:short)%(color:reset) \
  %(else)\
  %(if)%(upstream)%(then)\
  %(color:"#999999")%(objectname:short)%(color:reset) \
  %(color:"#222222")[%(committerdate:short)]%(color:reset) \
  %(refname:short) \
  %(color:"#ffc662")%(upstream:track)%(color:reset) \
  %(else)\
  %(color:"#963232")%(objectname:short)%(color:reset) \
  %(color:"#222222")[%(committerdate:short)]%(color:reset) \
  %(color:red)%(refname:lstrip=1)%(color:reset)\
  %(color:"#ffc662")%(upstream:track)%(color:reset) \
  %(end)\
  %(end)\
  '
Meaning

  HASH Commit_date Branch_Name

  A white branch_name means it is local.
  Red means it is remote.
  Yellow branch_name is the current branch.
  It will also tell you if your checked out branch is ahead or behind the remote branch.


This broke my Alacritty build:

  $ cargo build --release
  error: failed to get `bitflags` as a dependency of package `alacritty v0.9.0-dev (/home/myuser/sources/alacritty/alacritty)`
  
  Caused by:
    failed to initialize index git repository
  
  Caused by:
    failed to parse config file: invalid configuration key (in /home/myuser/.config/git/config:57); class=Config (7)


Yep, definitely among my top git aliases.

Google/DDG search for "git lg2" should also reliably take you to this SO answer to copy the alias from: https://stackoverflow.com/a/9074343




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: