Skip to content

Instantly share code, notes, and snippets.

@SynCap
Last active July 28, 2021 06:46
Show Gist options
  • Save SynCap/2df07987b939d5df2bae71d109824c81 to your computer and use it in GitHub Desktop.
Save SynCap/2df07987b939d5df2bae71d109824c81 to your computer and use it in GitHub Desktop.
Awesome Git Aliases

Add this to your ~/.gitconfig file.

[alias]

alias = config --get-regexp ^alias\\.
branches = branch --all
camend = commit --amend -m
co = checkout
d = difftool
discard = checkout --
ds = difftool --staged
fresh = filter-branch --prune-empty --subdirectory-filter
here = !git init && git add . && git commit -m \"Init\"
lonely = clone --single-branch --branch
main = checkout main
master = checkout master
plg = log --graph --pretty=format:'%C(yellow)%h%Creset -%Cred%d%Creset %s %Cgreen| %cr %C(bold blue)| %an%Creset' --abbrev-commit --date=relative
recommit = commit --amend --no-edit
rename = "!move() { git push origin --delete `git branch --show-current` || true; git branch -m $1; git push --set-upstream origin $1; }; move"
renameit = "!moveit { git branch -m $1 $2; git push origin :$1; git push --set-upstream origin $2; }; moveit"
root = 'rev-parse --show-toplevel'
search = grep
st = status -s -uno
unadd = restore --staged
unstage = restore --staged
who = blame
zip = archive --format=tar.gz -o ../repo.tar.gz
git config --global alias.alias 'config --get-regexp ^alias\\.'
git config --global alias.root 'rev-parse --show-toplevel'
git config --global alias.rename "!move() { git push origin --delete `git branch --show-current` || true; git branch -m $1; git push --set-upstream origin $1; }; move"
git config --global alias.renameit "!moveit { git branch -m $1 $2; git push origin :$1; git push --set-upstream origin $2; }; moveit"
git config --global alias.here '!git init && git add . && git commit -m \"Init\"'
git config --global alias.main 'checkout main'
git config --global alias.master 'checkout master'
git config --global alias.dev 'checkout dev'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment