Skip to content

Instantly share code, notes, and snippets.

@eyadsibai
Created August 6, 2018 08:57
Show Gist options
  • Save eyadsibai/f3a52cc1567934c22f76a0978031ea2d to your computer and use it in GitHub Desktop.
Save eyadsibai/f3a52cc1567934c22f76a0978031ea2d to your computer and use it in GitHub Desktop.
My Git Config
[user]
name = <Your Name>
email = name@domain.com
[color]
ui = auto
[color "branch"]
current = reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
[merge]
tool = vscode
log = true
[mergetool "vscode"]
cmd = code --wait $MERGED
[branch]
autosetuprebase = always
[push]
# instead of pushing all branches with git push, you only push the current one.
default = current
[core]
editor = code --wait -n
ignorecase = true
excludesfile = ~/.gitignore_global
# Treat spaces before tabs and all kinds of trailing whitespace as an error
# [default] trailing-space: looks for spaces at the end of a line
# [default] space-before-tab: looks for spaces before tabs at the beginning of a line
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
# global per user gitignore file
# excludesfile = ~/.gitignore
[alias]
st = status
branches = !legit branches
br = branch
co = checkout
ci = commit
df = diff
mod = submodule
fp = fetch --prune
l1 = log --graph
l3 = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
l2 = log --stat --no-merges
l4 = log --graph --pretty=format:'%Cred%h%Creset %an -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
changes = diff --name-status -r
diffstat = diff --stat -r
undo = reset --soft HEAD^
merge-dry = "!f() { git merge-tree `git merge-base $2 $1` $2 $1; }; f" #check how the merge of dev into master will go: git dry dev master
merge-wet = "!f() { git merge --no-commit --no-ff $1; }; f"
new = !sh -c 'git log $1@{1}..$1@{0} "$@"'
prune-all = !git remote | xargs -n 1 git remote prune
up = pull --ff-only --all -p
gra = "!f() { A=$(pwd) && TOPLEVEL=$(git rev-parse --show-toplevel) && cd $TOPLEVEL && git grep --full-name -In $1 | xargs -I{} echo $TOPLEVEL/{} && cd $A; }; f"
grep = grep -Ii
f = "!git ls-files | grep -i"
la = "!git config -l | grep alias | cut -c 7-"
assume = update-index --assume-unchanged
unassume = update-index --no-assume-unchanged
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
unassumeall = "!git assumed | xargs git update-index --no-assume-unchanged"
assumeall = "!git st -s | awk {'print $2'} | xargs git assume"
lasttag = describe --tags --abbrev=0
ours = "!f() { git co --ours $@ && git add $@; }; f"
theirs = "!f() { git co --theirs $@ && git add $@; }; f"
diff = diff --word-diff
dc = diff --cached
r = reset
r1 = reset HEAD^
r2 = reset HEAD^^
rh = reset --hard
rh1 = reset HEAD^ --hard
rh2 = reset HEAD^^ --hard
sl = stash list
sa = stash apply
ss = stash save
dl = "!git ll -1"
dlc = diff --cached HEAD^
branch-dates = "!f() { git for-each-ref --sort=committerdate refs/${1:-heads}/ --format='%(committerdate:short)\t%(authorname)\t%(refname:short)' | sed 's_origin/__g' | column -t -s' ' ; } ; f"
# Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
graft = !legit graft
harvest = !legit harvest
publish = !legit publish
unpublish = !legit unpublish
sprout = !legit sprout
sync = !legit sync
switch = !legit switch
resync = !legit resync
cleanup-local = "!git branch --merged | grep -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d"
# cleanup-origin = "!git branch -r --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin"
[gc]
auto = 0
[pull]
ff = only
rebase = true
autostash = true
[help]
autocorrect = 1
[filter "media"]
clean = git media clean %f
smudge = git media smudge %f
required = true
[apply]
whitespace = fix
# URL shorthands
[url "git@github.com:"]
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
insteadOf = "github:"
[url "git@gist.github.com:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
[url "git://gist.github.com/"]
insteadOf = "gist:"
[pull "rebase"]
autostash = true
[rebase]
autoStash = true
[credential]
helper = cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment