Skip to content

Instantly share code, notes, and snippets.

@mihajloS
Last active September 30, 2026 18:22
Show Gist options
  • Select an option

  • Save mihajloS/427394301a60ca306ddc7330beb059b6 to your computer and use it in GitHub Desktop.

Select an option

Save mihajloS/427394301a60ca306ddc7330beb059b6 to your computer and use it in GitHub Desktop.
Github aliases
# git cli alias performance toolkit
alias gs='git status'
alias gc='git checkout'
alias gp='git push'
alias gp!='git push --force-with-lease'
alias ga='git commit --amend'
alias ga!='git commit --amend --no-edit'
alias grs='git restore --staged'
alias grs!='git restore --staged .'
alias pull='git pull --rebase'
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# last 10 branches I committed to
alias glb="git for-each-ref --sort=-committerdate --count=10 refs/heads/ --format='%(committerdate:relative) %(refname:short)'"
#workflow inline example, where you amend last commmit with latest changes
#git add . && ga! && gp!

Git aliases

Copy the block from .zshrc into your shell config. The ! variants are the "force" versions of the plain alias.

Daily

Alias Expands to What for
gs git status what changed
gc git checkout switch branch
pull git pull --rebase update branch without merge commits
gp git push push
gp! git push --force-with-lease force push after amend or rebase, refuses if remote moved
ga! git commit --amend --no-edit fold staged changes into the last commit
gl git log --graph --pretty=format:... compact graph log with age and author
glb git for-each-ref --sort=-committerdate --count=10 ... last 10 branches I committed to

Rarely used

Alias Expands to What for
ga git commit --amend amend and edit the message
grs git restore --staged unstage a file
grs! git restore --staged . unstage everything

Workflow

Amend the last commit with the latest changes and force push:

git add . && ga! && gp!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment