Skip to content

Instantly share code, notes, and snippets.

@xphere
Last active May 19, 2021 10:15
Show Gist options
  • Save xphere/77e9ccc0950c696b1101 to your computer and use it in GitHub Desktop.
Save xphere/77e9ccc0950c696b1101 to your computer and use it in GitHub Desktop.
[alias]
b = branch
bl = branch-list
bn = rename-branch
br = branch -r
c = checkout
cm = commit -m
cp = cherry-pick
d = diff
df = commits-of-changed-files
dn = diff --name-only
ds = diff --staged
dsn = diff --staged --name-only
f = fetch --no-tags
fr = fetch-rebase
is = current-directory-is-git-managed
l = log-tree @{u}..
la = log-tree --all
ll = log-tree
p = add -p
pr = pull --rebase
r = reset
rc = rebase --continue
rh = reset --hard
ri = rebase --interactive
rs = reset --soft
rt = remote-track
s = status -sbu
si = status -sbu --ignored
sp = status --porcelain
u = checkout @{u}
up = !git push $(git rt) $(git current)
uf = !git push --force-with-lease $(git rt) $(git current)
x = "!exec "
z = undo
alias = "!f() { git config --get-regexp ^alias\\.$1 | sed -E 's/alias\\.([^ ]+)/\\1 =/' | sort; }; f"
alias-of = "!f() { git alias $1\\$; }; f"
amend = commit --amend --no-edit
current = rev-parse --abbrev-ref HEAD
debug = !GIT_TRACE=1 git
discard = !git reset --hard && git clean -df
edit = commit --amend --edit
exec = "!exec "
fixup = commit --fixup
git = !exec git
ignore = "!f() { echo $@ >> .gitignore; }; f"
last = rev-parse --short HEAD
new = add -N
prune = !git reflog expire --expire=now --all && git gc --prune=now
rev = rev-parse HEAD
recover = "!f() { local REV=$(git rev); [ \"$(git message)\" = ::modified ] && git reset -q HEAD~; [ \"$(git message)\" = ::indexed ] && git reset -q --soft HEAD~; [ $(git rev) = $REV ] || echo 'Current state recovered'; }; f"
remote-track = "!f() { git config \"branch.$(git current).remote\"; }; f"
root = rev-parse --show-toplevel
search = log -S
stale = "!f() { for BRANCH in $(git unmerged); do (git rev-parse --verify --quiet \"$BRANCH\"@{u} > /dev/null 2>&1 && git merge-base --is-ancestor \"$BRANCH\"@{u} \"$BRANCH\") || echo \"$BRANCH\"; done }; f"
start = !git init . && git commit --allow-empty -m 'Initial commit'
store = "!f() { local REV=\"$(git rev)\"; git index-is-clean || git unsafe-commit '::indexed'; git working-is-clean || $(git add -A && git unsafe-commit '::modified'); [ \"$(git rev)\" = \"$REV\" ] || echo 'Current state stored'; }; f"
undo = "!f() { git r $@ && git c $@; }; f"
unmerged = "!f() { git bl | xargs git merge-base --independent ${1:-} | xargs git name-rev --name-only; }; f"
branch-list = for-each-ref -s --format '%(refname:short)' refs/heads/
commits-of-changed-files = !git log --format='%h %s' @{u}.. -- $(git dsn)
current-directory-is-git-managed = ![ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1
fetch-rebase = "!f() { local BRANCH=${1-$(git current)}; git f origin \"$BRANCH\" && git rebase $(git merge-base FETCH_HEAD \"${BRANCH}\") --onto FETCH_HEAD; }; f"
index-is-clean = !git diff-index --cached --quiet HEAD
log-tree = log --graph --pretty=line
message = show -s --format="%s"
rename-branch = "!f() { git update-ref \"refs/heads/$1\" \"${2-HEAD}\"; }; f"
unsafe-commit = !git commit --no-verify -q -m
working-is-clean = !git diff-files --quiet && [ -z \"$(git ls-files --exclude-standard --others)\" ]
[branch]
autosetupmerge = always
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
frag = magenta bold
meta = yellow bold
new = green bold
old = red bold
whitespace = red reverse
[color "status"]
added = yellow
changed = green
untracked = cyan
[core]
autocrlf = false
excludesfile = ~/.gitexclude
filemode = true
lagallrefupdates = true
safecrlf = true
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
[diff]
algorithm = histogram
mnemonicprefix = true
indentheuristic = true
[http]
postBuffer = 524288000
receivepack = true
[merge]
tool = meld
[mergetool]
prompt = false
keepBackup = false
[mergetool "meld"]
keepbackup = false
[pretty]
line = %C(auto)%h %s%d %C(blue)<%an>%C(green) %ar
simple = %C(auto)%h %s
[push]
default = simple
[pull]
rebase = true
[rebase]
autosquash = true
autostash = true
[rerere]
enabled = true
[commit]
gpgsign = true
[remote "origin"]
tagOpt = --no-tags
[user]
name = Username
email = username@subdomain.domain.tld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment