Skip to content

Instantly share code, notes, and snippets.

@feoche
Last active January 31, 2022 17:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feoche/915cee8557563076863f21f03b93cbad to your computer and use it in GitHub Desktop.
Save feoche/915cee8557563076863f21f03b93cbad to your computer and use it in GitHub Desktop.
My detailed .gitconfig
[alias]
# Discard duplicate leading “git” (e.g. “git git status”)
git = "!git"
# add all files
aa = add --all
# abort current rebase
abort = rebase --abort
# amends with previous commit
amend = commit --amend --no-edit
# list branches
br = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
# delete targeted branch
# ex: git brd wip/toto
brd = branch -d
# delete with force targeted branch
# ex: git brDf wip/toto
brDf = "!f() { git brD $1 && git push --delete origin $1; }; f"
# clones repo
# ex: git cl github.com/toto/toto.git
cl = clone
# checkout selected branch, if branch doesn't exist then create it
# ex: git co develop
# ex: git co feat/toto
co = "!f() { git show-branch ${1-master} &>/dev/null && git checkout ${1-master} || git checkout -b ${1-master}; }; f"
# list these aliases
commands = "!git config -l | grep alias | cut -c 7-"
continue = rebase --continue
# checkout existing branch (or master by default) and updates it
# ex: git cou
# ex: git cou develop
cou = "!f() { git co ${1-master} && git up; }; f"
# commit with message
# ex: git cm "feat(test): this is a test"
cm = cz
# commit without verifying
cmn = commit -m --no-verify
# cherry-pick a specific commit
# ex: git cp e0251ce02c
cp = cherry-pick
# show current branch
current = !git branch | grep '*' | sed 's/* //'
# prettify diff :D
diff = diff --word-diff --color
# amend commit and push force it
fam = "!f() { git add . && git amend && git pf; }; f"
# clean your local changes to be aligned with last commit
fuck = reset --hard HEAD^
# fetch remote branch
fp = fetch -p
# prettify the Git logging
ll = log --color --graph --pretty=format:'%C(red)%h%Creset -%C(yellow)%d%Creset %s %C(green)(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all
# push to origin current branch (force)
pshf = push origin HEAD --force-with-lease
# push to origin current branch
psh = push origin HEAD
# fetches and rebases current branch
pr = pull --rebase --autostash --prune
# remove local branches that does not exist on remote
prune = "!sh -c 'git fetch -p && for branch in $(git branch -vv | grep ': gone]' | awk '{print $1}'); do git branch -D $branch; done' -"
# search commit by sha1
sha = "!sh -c 'git rev-list --all | grep ^$1 | while read commit; do git --no-pager log -n1 --pretty=format:\"%H %ci %an %s%n\" $commit; done' -"
skip = rebase --skip
# show Git status
st = status
# prepare yourself for the next standup
standup = !git log --all --author=$USER --since='9am yesterday' --format=%s
# list tags
tags = tag -l
# undo local commit but keeps local changes
undo = reset HEAD~1 --mixed
# fetches, remove useless branches & updates submodules
up = "!f() { git branch --set-upstream-to=origin/$(git current) $(git current) && git pr; }; f"
# rebases current branch with selected branch
# ex: git upwith develop (on feat/toto branch)
upwith = "!f() { git checkout $1 --force && git pull --rebase && git checkout - --force && git rebase $1; }; f"
prune-branches = !git remote prune origin && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs -r git branch -d
[color]
branch = auto
diff = auto
status = auto
ui = auto
[color "branch"]
current = red reverse
local = blue
remote = green
[color "diff"]
frag = magenta
meta = yellow
new = green
old = red bold
plain = white
[color "status"]
added = yellow
changed = green
untracked = cyan
[commit]
template = ~/.gitmessage
verbose = true
[core]
autocrlf = input
editor = /usr/bin/nano
eol = lf
excludesfile = ~/.gitignore
ignoreCase = false
whitespace = -trailing-space
[diff]
colorMoved = zebra
indentHeuristic = true
# Use better, descriptive initials (c, i, w) instead of a/b.
mnemonicPrefix = true
# Show renames/moves as such
renames = true
# Display submodule-related information (commit listings)
submodule = log
[difftool]
prompt = false
[fetch]
fsckobjects = true
prune = true
# Auto-fetch submodule changes (sadly, won’t auto-update)
recurseSubmodules = on-demand
[filter "media"]
clean = git media clean %f
required = true
smudge = git media smudge %f
[help]
autocorrect = 1
[log]
# Use abbrev SHAs whenever possible/relevant instead of full 40-chars
abbrevCommit = true
# Disable decorate for reflog
decorate = false
# Automatically --follow when given a single path
follow = true
[merge]
# Display common-ancestor blocks in conflict hunks
conflictstyle = diff3
[mergetool]
# Clean up backup files created by merge tools on tool exit
keepBackup = false
# Clean up temp files created by merge tools on tool exit
keepTemporaries = false
# Auto-accept file prompts when launching merge tools
prompt = false
# Put the temp files in a dedicated dir anyway
writeToTemp = true
[mergetool]
keepBackup = false
[pager]
difftool = true
[pull]
default = current
rebase = true
[push]
default = current
[rebase]
autostash = true
autosquash = true
[rerere]
enabled = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment