My Favorite Git Aliases

Shorter status


$ git config --global alias.st "status -sb"

Concise log


 $ git config --global alias.lg "log --color --decorate --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

Amend the last commit


 $ git config --global alias.amend "commit --amend --reuse-message=HEAD"

List all branches, including remote branches

 $ git config --global alias.br "branch -av"

Checkout


 $ git config --global alias.co "checkout"

Commit


 $ git config --global alias.ci "commit"

Discard changes in working directory


 $ git config --global alias.discard "checkout --"

Show the last commit


 $ git config --global alias.last "log -1 HEAD --stat"

List aliases


 $ git config --global alias.aliases "config --get-regexp alias"

Undo last commit


 $ git config --global alias.undo "reset HEAD~1 --mixed"

Show verbose output about tags, branches, or remotes


 $ git config --global alias.tags "tag -l"
 $ git config --global alias.branches "branch -a"
 $ git config --global alias.remotes "remote -v"

Pull changes and rebase


 $ git config --global alias.preb "pull --rebase"

Push force with lease (safer than force push)


 $ git config --global alias.pushf "push --force-with-lease"

Interactive rebase


 $ git config --global alias.rebase-i "rebase -i"

Stash changes


 $ git config --global alias.stash-all "stash save --include-untracked"

Serve the repository on a temporary web server


 $ git config --global alias.serve "!git daemon --reuseaddr --verbose --base-path=. --export-all ./.git"