Skip to content

Instantly share code, notes, and snippets.

@felipesabino
Last active February 8, 2022 23:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save felipesabino/6391408 to your computer and use it in GitHub Desktop.
Save felipesabino/6391408 to your computer and use it in GitHub Desktop.
gitconfig
[alias]
com = commit -m
ck = checkout
po = push origin
mg = merge --no-ff
st = status -sb
br = ls-remote
lc = ls-files -u
ls = ls -la
a = add -A :/
s = status -sb
fo = fetch origin
fpo = fetch -p origin
fp = fetch -p
cl = clean -fdx
df = diff --color --color-words --abbrev
# GPG Signed commands
# https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work
coms = commit -S -m
comas = commit -S --amend
tags = tag -s
logs = log --show-signature -1
loggs = log --pretty="format:%h %G? %aN %s"
rbs = rebase -S
bd = "!f() { git branch -D $1; git push origin --delete $1; }; f"
# positional aliases
# from: http://stackoverflow.com/a/3322412/429521
ro = "!f() { git checkout $1; git reset --hard origin/$1; }; f" # usage: $ git ro master
pof = "!f() { git push --force origin $1; }; f" # usage: $ git pof master
poc = push origin
# alias bellow from http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/
logk = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
logf = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lg = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
logm = log --merges --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
dl = "!git logf -1"
alias = "!git config -l | grep alias | cut -c 7-"
switch = !legit switch \"$@\"
branches = !legit branches
sprout = !legit sprout \"$@\"
unpublish = !legit unpublish \"$@\"
harvest = !legit harvest \"$@\"
sync = !legit sync \"$@\"
publish = !legit publish \"$@\"
graft = !legit graft \"$@\"
# alias bellow from http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/
assume = update-index --assume-unchanged
unassume = update-index --no-assume-unchanged
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
snapshot = !git stash save "snapshot: $(date)" && git stash apply "stash@{0}"
ours = "!f() { git checkout --ours $@ && git add $@; }; f"
theirs = "!f() { git checkout --theirs $@ && git add $@; }; f"
[color]
ui = auto
grep = auto
interactive = auto
[color "branch"]
current = yellow 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
[advice]
pushNonFastForward = false
statusHints = false
[diff]
renames = copies
[merge]
stat = true
tool = opendiff
[mergetool]
keepBackup = false
prompt = false
[rerere]
enabled = 0
[core]
pager = less -r
[merge "ours"]
driver = true
[filter "media"]
clean = git-media-clean %f
smudge = git-media-smudge %f
@felipesabino
Copy link
Author

@lgfa29 pretty nice, added :)

@thalescm
Copy link

There's also some good ones for deleting:

# deleting branch localy, remote and both
del = branch -D
delo = push origin --delete
delboth = "!f() { git del $1; git delo $1; }; f" # usage: $ git delboth master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment