Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@anied
Last active January 24, 2024 19:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anied/fb7b9abdfe861205b23ed78be2a05a1a to your computer and use it in GitHub Desktop.
Save anied/fb7b9abdfe861205b23ed78be2a05a1a to your computer and use it in GitHub Desktop.
My Git Aliases
# Mostly the same as git-alias.sh, but simplified for Oh My Zsh (because it handles the piping to a text buffer for you)
# Nice logs
git config --global alias.l 'log --graph --decorate --branches --remotes'
# Nice condensed logs
git config --global alias.lp 'log --graph --decorate --branches --remotes --pretty=format:"%C(auto) %h %d %s"'
# Diff
git config --global alias.d 'diff'
# Diff Staged
git config --global alias.ds 'diff --staged'
# Status
git config --global alias.s 'status -u'
# Clear all changes and untracked files
git config --global alias.wipe '! git reset --hard && git clean -f -d'
# Checkout
git config --global alias.c 'checkout'
# Branch
git config --global alias.b 'branch'
# Generate rebase rescue tag
git config --global alias.rrt '!f() { \
local x="$1"; \
local timestamp=$(date "+%Y%m%d%H%M"); \
local tag="RR_${x}_$timestamp"; \
git tag "$tag"; \
}; f'
# See all aliases
git config --global alias.aliases 'config --get-regexp alias'
# A list of all the git aliases I've been cultivating over the years
# Nice logs
git config --global alias.l '! git log --graph --decorate --branches --remotes --color=always | less -r'
# Nice condensed logs
git config --global alias.lp '! git log --graph --decorate --branches --remotes --pretty=format:"%C(auto) %h %d %s" --color=always | less -r'
# Diff
git config --global alias.d '! git diff --color=always | less -r'
# Diff Staged
git config --global alias.ds 'diff --staged --color=always | less -r'
# Status
git config --global alias.s 'status -u'
# Clear all changes and untracked files
git config --global alias.wipe '! git reset --hard && git clean -f -d'
# Checkout
git config --global alias.c 'checkout'
# Branch
git config --global alias.b '! git branch --color=always | less -r'
# Generate rebase rescue tag
git config --global alias.rrt '!f() { \
local x="$1"; \
local timestamp=$(date "+%Y%m%d%H%M"); \
local tag="RR_${x}_$timestamp"; \
git tag "$tag"; \
}; f'
# See all aliases
git config --global alias.aliases '! git config --get-regexp alias'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment