Skip to content

Instantly share code, notes, and snippets.

@gokure
Last active March 3, 2025 02:00
Show Gist options
  • Save gokure/3488458 to your computer and use it in GitHub Desktop.
Save gokure/3488458 to your computer and use it in GitHub Desktop.
dot gitconfig file
[user]
name = <Your name>
email = <[email protected]>
[alias]
co = checkout
ci = commit
st = status
br = branch -v
rt = reset --hard
df = diff
dc = diff --cached
unstage = reset HEAD
uncommit = reset --soft HEAD^
l = log --graph --decorate --pretty=oneline --abbrev-commit
la = log --graph --decorate --pretty=oneline --abbrev-commit --all
lg = log --graph --decorate --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all
lp = log -p
ls = ls-files
amend = commit --amend
who = shortlog -n -s --no-merges
g = grep -n --color -E
cp = cherry-pick -x
nb = checkout -b
addall = !sh -c 'git add . && git add -u'
# Upstream merge:
upsmerge = !sh -c 'git fetch origin -v && git fetch upstream -v && git merge upstream/master'
# Show files ignored by git:
ign = ls-files -o -i --exclude-standard
# git change-commits GIT_COMMITTER_NAME "old name" "new name"
# git change-commits GIT_COMMITTER_EMAIL "[email protected]" "[email protected]"
change-commits = "!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [[ \\\"$`echo $VAR`\\\" = '$OLD' ]]; then export $VAR='$NEW'; fi\" $@; }; f"
# Deal with "There is no tracking information for the current branch."
# See: https://zarino.co.uk/post/git-set-upstream/
poh = push origin HEAD
pulloh = pull origin HEAD
set-upstream = !git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`
[apply]
whitespace = nowarn
[commit]
template = ~/.stCommitMsg
[color]
diff = auto
status = auto
branch = auto
[color "status"]
added = green bold
changed = red bold
untracked = red
branch = yellow black bold ul
[core]
excludesfile = ~/.gitignore_global
editor = vim
autocrlf = input
ignorecase = false
[fetch]
prune = true
[format]
pretty = %C(yellow)%H%Creset %s %C(red)(%an, %cr)%Creset
#[http]
# proxy = http://127.0.0.1:7890
# postBuffer = 524288000
# version = HTTP/1.1
#[https]
# proxy = http://127.0.0.1:7890
[includeIf "gitdir:~/work/"]
path = ~/.gitinc/work/config
[includeIf "gitdir:~/play/"]
path = ~/.gitinc/play/config
[init]
defaultBranch = main
[i18n]
filesEncoding = utf-8
logoutputencoding = utf-8
[push]
default = current
autoSetupRemote = true
[pull]
rebase = false
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[github]
name = <Your github account>
[url "https://<username>:<personal_access_token>@git.example.com"]
insteadOf = https://git.example.com
# ~/gitinc/play/config
[user]
name = <Your Name>
email = <[email protected]>
[core]
hooksPath = ~/.gitinc/play/hooks
# ~/.gitinc/work/config
[user]
name = <Your Name>
email = <[email protected]>
[core]
hooksPath = ~/.gitinc/work/hooks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment