Skip to content

Instantly share code, notes, and snippets.

@aalmeida00
Last active April 4, 2025 20:28
Git aliases / commands to use
  1. Git log
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

image

  1. Git last branch
git config --global alias.lb '!git branch --sort=-committerdate --format="%(HEAD)%(color:yellow)%(re
fname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)" --color=always | co
lumn -t -s "|"'

image

  1. Rename all commits Author in a branch
NEW_NAME="New Author Name"
NEW_EMAIL="newauthor@example.com"

export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
' -- --all
  1. Avoid use --set-upstream to git push of new branches

image

git config --global push.default current
git config --global push.autoSetupRemote true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment