Skip to content

Instantly share code, notes, and snippets.

@sustmi
Created January 8, 2018 10:48
Show Gist options
  • Save sustmi/377fcd13a8b63774b1a91daf1456263a to your computer and use it in GitHub Desktop.
Save sustmi/377fcd13a8b63774b1a91daf1456263a to your computer and use it in GitHub Desktop.
Example Git config with useful aliases
[user]
name = Miroslav Sustek
email = miroslav.sustek@shopsys.com
[core]
# "true" on Windows; "input" on Linux
autocrlf = input
[push]
default = simple
[merge]
# show "merged common ancestors" (base version of both sides) section in git conflict
conflictstyle = diff3
[alias]
f = fetch
# updates your branch with upstream (if fast-forward is possible)
ff = !git merge --ff-only `git rev-parse --symbolic-full-name --abbrev-ref=strict HEAD@{u}`
fp = fetch --prune
st = status
cm = commit
cma = commit --amend
br = branch
co = checkout
cp = cherry-pick
df = diff
rb = rebase
rbi = rebase --interactive --autosquash
rbc = rebase --continue
rh = reset --hard
su = submodule update
# graph for current branch
l = log --graph --decorate --pretty=oneline --abbrev-commit
# graph for all branches
ll = log --graph --decorate --pretty=oneline --abbrev-commit --all
# graph for all branches including commit time and author
lll = log --graph --decorate --all --date-order \"--pretty=format:%C(yellow)%h%C(reset)%C(auto)%d %s %C(green)(%ai%x08%x08%x08%x08%x08%x08)%C(reset) %C(blue)<%an>%C(reset)\"
# log for current branch showing diffs (-m is for showing mergecommits too)
ld = log -p -m
# log for current branch showing summary of changed files (-m is for showing mergecommits too)
ls = log --stat -m
# number of commits for each person
stats = shortlog -n -s --no-merges
# remove remote branch (remote must be named origin), usage: git rmb test
rmb = !sh -c 'git push origin :$1' -
# shows local > tracked remote
brt = for-each-ref --format=\"%(refname:short) > %(upstream:short)\" refs/heads
# get upstream tracked branch or error
brtracked = rev-parse --symbolic-full-name --abbrev-ref=strict HEAD@{u}
# list all branches already merged to origin/master
brmerged = branch --list --all --merged origin/master
# commit all changes to a WIP commit
wip = !git add $(git rev-parse --show-toplevel) && git commit -m WIP
# reset last WIP commit
unwip = "!sh -c 'if [ -n \"$(git log -n 1 --format=\\\"format:%s\\\"|grep WIP)\" ]; then git reset --soft HEAD~1; else echo \"No WIP to unwip\"; fi'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment