Skip to content

Instantly share code, notes, and snippets.

@markatom
Last active October 3, 2022 09:08
Show Gist options
  • Save markatom/08628eb36f0c747bcebc106e39b78b4f to your computer and use it in GitHub Desktop.
Save markatom/08628eb36f0c747bcebc106e39b78b4f to your computer and use it in GitHub Desktop.
Personal .gitconfig
[core]
excludesfile = ~/.gitignore
editor = nvim
pager = BAT_PAGER='less -iRx4' delta -n --theme='darcula' --highlight-removed --hunk-style plain
[user]
name = Tomáš Markacz
email = [email protected]
[remote]
pushDefault=origin
[pretty]
custom = %Cblue%h %Cgreen%an %C(yellow)%ar%Cred%d%n%Creset%s
[color]
ui = true
[color "diff-highlight"]
oldNormal = "red bold"
oldHighlight = "red bold 52"
newNormal = "green bold"
newHighlight = "green bold 22"
[color "diff"]
meta = "yellow"
frag = "magenta bold"
commit = "yellow bold"
old = "red bold"
new = "green bold"
whitespace = "red reverse"
[rerere]
enabled = false
[merge]
keepBackup = false;
tool = p4merge
[push]
followTags = true
default = current
[sequence]
# editor = rebase-editor
[alias]
a = add
aa = add . # add --all
ai = add --interactive
b = branch
br = branch --sort=committerdate
bm = branch --move
c = commit
ca = "!git add .; git commit # commit --all"
cm = commit --amend
cam = "!git add .; git commit --amend # commit --all --amend"
cf = commit --fixup
caf = "! f() { \
git add .; \
git commit --fixup $1; \
}; f"
d = diff
dc = "! { \
git diff HEAD; \
for untracked in `git ls-files --others --exclude-standard`; do \
git diff /dev/null $untracked; \
done; \
} | BAT_PAGER='less -iRx4' delta -n --theme='darcula' --highlight-removed --hunk-style plain"
do = !git diff HEAD origin/$(git get-branch)
ds = diff --staged
e = reset
ec = "!git reset --hard HEAD; git clean -df"
eh = reset --hard
eho = !git reset --hard origin/$(git get-branch)
ep = reset HEAD^
h = cherry-pick
hc = cherry-pick --continue
o = restore
v = revert
f = fetch --tags
l = log --graph --pretty=custom
la = !git l --all
lf = !git l --first-parent
lm = !git l master...HEAD
lo = !git l HEAD...origin/$(git get-branch)
m = merge
mn = merge --no-ff
# o = checkout
# ob = checkout -b
# om = checkout --merge
i = switch
ic = switch --create
icf = switch --force-create
id = switch --detach
p = push
pf = push --force-with-lease
pff = push --force
pu = push --set-upstream origin HEAD
pdo = push --delete origin
r = rebase
ra = rebase --abort
rc = rebase --continue
ri = rebase --interactive
ria = rebase --interactive --autosquash
ro = rebase --onto
rrm = rebase --rebase-merges
rrmo = rebase --rebase-merges --onto
s = status --untracked-files
t = stash -u
ta = stash apply
tb = stash branch
td = stash drop
tl = stash list
tp = stash pop
ts = stash save -u
tsp = stash save --patch
tw = stash show
w = show
wn = show --name-only
x = "! f() { \
git commit --all --fixup $1; \
GIT_SEQUENCE_EDITOR=: git rebase --interactive --autosquash "$1^"; \
}; f"
xx = "! \
git reset; \
OLD_HEAD=$(git rev-parse HEAD); \
for FILE in $(git status --porcelain | cut -c 4- | sed -Ee 's/.* -> (.*)/\\1/'); do \
git add $FILE; \
git commit --fixup $(git --no-pager log -1 --format='%H' -- $FILE); \
done; \
git l $OLD_HEAD..HEAD; \
echo Undo with: git e ${OLD_HEAD:0:9}; \
"
get-branch = rev-parse --abbrev-ref HEAD
get-hash = rev-parse HEAD
uncommit = "!git rev-parse HEAD > $TMPDIR/uncommit-hash; git reset --soft HEAD^"
recommit = "!git commit --reedit-message $(cat $TMPDIR/uncommit-hash)"
prev = "!git switch --detach $(git rev-parse HEAD^)"
next = "! f() { \
git switch --detach $(git --no-pager log --reverse --format='%H' HEAD..${1-master} | head -n 1); \
}; f"
conflicting-history = "! \
CONFLICTING_FILES=$(git ls-files -u | cut -f 2 | sort); \
for FILE in $CONFLICTING_FILES; do \
echo $FILE; \
git --no-pager log --graph --pretty=custom HEAD@{1}..HEAD -- $FILE; \
echo; \
done; \
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment