Skip to content

Instantly share code, notes, and snippets.

@aalmeida00
Last active July 31, 2025 20:12
Show Gist options
  • Select an option

  • Save aalmeida00/b87181f76785b2413d06e56dc6c499db to your computer and use it in GitHub Desktop.

Select an option

Save aalmeida00/b87181f76785b2413d06e56dc6c499db to your computer and use it in GitHub Desktop.
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 --color=always --format="%(HEAD)%(color:yellow)%(refname:short)%(color:reset) %(color:green)%(committerdate:relative)%(color:reset) %(color:blue)%(subject)%(color:reset) %(color:magenta)%(authorname)%(color:reset)" | head -n 3'

image

  1. Rename all commits Author in a branch
git filter-branch -f --env-filter '
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"
' -- HEAD~31..HEAD
  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