Skip to content

Instantly share code, notes, and snippets.

@Vadorequest
Last active February 27, 2025 06:35
My own Git config
# Gist: https://gist.github.com/Vadorequest/9d1f86b19dff5e1f7946a2f6b15a97f3
# Best practices: See https://blog.gitbutler.com/how-git-core-devs-configure-git
[push]
default = simple
autoSetupRemote = true
followTags = true
[alias]
fetch = git fetch --tags
reflog = git reflog --date=iso
st = status
ci = commit
co = checkout
br = branch
rz = reset --hard HEAD
unwip = reset HEAD^
pr = pull --rebase
cp = cherry-pick
oops = commit --amend --no-edit
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
wip = !git add --all && git ci -am "wip"
amend = !git add --all && git ci --amend
fake = !git commit --allow-empty -m "chore-fake-re-trigger-build"
branch-alias-master = "!f() {\
branch=$1;\
git symbolic-ref refs/heads/master refs/heads/${branch};\
}; f"
fix = "!f() {\
orig=$(git rev-parse --abbrev-ref HEAD);\
branch=$1;\
git checkout -b ${branch};\
git add --all;\
git commit;\
git push --set-upstream origin ${branch};\
git checkout ${orig};\
}; f"
ls = show --stat --oneline
rollback = reset --soft HEAD~1
rebase-and-delete = "!f() {\
if [ ! $1 ]; then exti 0; fi;\
orig=$(git rev-parse --abbrev-ref HEAD);\
branch=$1;\
git pull --rebase;\
git checkout ${branch};\
git pull --rebase origin ${orig} || exit 0;\
git push -f;\
git checkout ${orig};\
git rebase ${branch};\
git push;\
git branch -D ${branch};\
git push origin :${branch};\
}; f"
# Delete all local branches but master and the current one, only if they are fully merged with master.
br-delete-useless = "!f(){\
git branch | grep -v "master" | grep -v ^* | xargs git branch -d;\
}; f"
# Delete all local branches but master and the current one.
br-delete-useless-force = "!f(){\
git branch | grep -v "master" | grep -v ^* | xargs git branch -D;\
}; f"
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow
frag = magenta
old = red
new = green
[color "status"]
added = yellow
changed = green
untracked = cyan
[core]
editor = 'subl' --wait
trustctime = false
autocrlf = input
[fetch]
prune = true
pruneTags = true
all = true
[status]
showUntrackedFiles = all
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[pull]
rebase = true
[init]
defaultBranch = main
# Use a different .gitconfig file for each Git identity
[includeif "gitdir:~/dev/vadorequest/"]
path = ~/dev/vadorequest/.gitconfig
[includeif "gitdir:~/dev/unlyEd/"]
path = ~/dev/vadorequest/.gitconfig
[includeif "gitdir:~/dev/dna-pc/"]
path = ~/dev/dna-pc/.gitconfig
[column]
ui = auto
[branch]
sort = -committerdate
[tag]
sort = version:refname
[diff]
algorithm = histogram
colorMoved = plain
mnemonicPrefix = true
renames = true
[help]
autocorrect = prompt
[rerere]
enabled = true
autoupdate = true
[merge]
conflictstyle = zdiff3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment