Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SandroMachado/7ecb1f2d7ffde3738fb9c810e33247b5 to your computer and use it in GitHub Desktop.
Save SandroMachado/7ecb1f2d7ffde3738fb9c810e33247b5 to your computer and use it in GitHub Desktop.
.gitconfig
[alias]
# branch (verbose)
br = branch -v
# commit
ci = commit --verbose
# amend your last commit
amend = commit --amend --verbose
# amend your last commit
ammend = commit --amend --verbose
# cleanup local branches after they have been merged
cleanup = "!git branch -vvv | grep ': gone]' | grep -v '\\*' | awk '{ print \"git branch -D\", $1 }' | bash"
# checkout
co = checkout
# checkout pr #<nr>
co-pr = !sh -c 'git fetch origin pull/$1/head:pr/$1 && git checkout pr/$1' -
# fixup
fixup = !sh -c 'git commit -m \"fixup! $(git log -1 --format='\\''%s'\\'' $@)\"' -
# pretty log
lg = log --graph --pretty='format:%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
lost = !"git fsck | awk '/dangling commit/ {print $3}' | git show --format='SHA1: %C(yellow)%h%Creset %f' --stdin | awk '/SHA1/ {sub(\"SHA1: \", \"\"); print}'"
# push (promote) your branch to remote origin and track it
# this is useful the first time you try to push a new local branch to origin
promote = "!git push -u origin ${1:-HEAD}"
# rebase
rb = rebase
ri = rebase --interactive --autosquash
# commit with squash tag
squash = !sh -c 'git commit -m \"squash! $(git log -1 --format='\\''%s'\\'' $@)\"' -
# status
st = status
# working in progress commit
unwip = !"git log -n 1 | grep -q -c wip && git reset HEAD~1"
wip = !"git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m \"wip [ci skip]\" --no-verify"
[apply]
whitespace = fix
[branch]
autosetuprebase = always
[core]
attributesfile = ~/.gitattributes
autocrlf = input
editor = vim
excludesfile = /opt/dotfiles/git/gitignore
quotepath = false
safecrlf = true
whitespace = cr-at-eol,space-before-tab,-indent-with-non-tab,trailing-space
[fetch]
prune = true
[format]
pretty = %Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset
[init]
templatedir = /opt/dotfiles/git/git-templates
[pull]
rebase = preserve
[push]
default = current
[rebase]
autosquash = true
autostash = true
stat = true
[rerere]
enabled = 1
autoupdate = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment