-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.gitconfig
136 lines (114 loc) · 5.88 KB
/
.gitconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
[user]
email = [email protected]
name = Felix Dietze
[init]
defaultBranch = main
templateDir = /home/felix/.config/git/templates
[pager]
diff = diff-so-fancy | less --RAW-CONTROL-CHARS
show = diff-so-fancy | less --RAW-CONTROL-CHARS
log = diff-so-fancy | less --RAW-CONTROL-CHARS
reflog = diff-so-fancy | less --RAW-CONTROL-CHARS
[push]
default = simple
followTags = true # Automatically pushes annotated tags (but not leightweight tags!)
[pull]
ff = only
rebase = true
[fetch]
prune = true # remove old branches on fetch
[branch]
autosetuprebase = always
[merge]
; ff = only
ignore-space-change = true
conflictstyle = diff3 # this allows to show 3 panes in meld, https://stackoverflow.com/questions/27417656/should-diff3-be-default-conflictstyle-on-git/70387424#70387424
[rerere]
enabled = 1 # Reuse recorded resolution of conflicted merges: https://git-scm.com/docs/git-rerere
[rebase]
autoStash = true
autoSquash = true # useful for `git commit --fixup <hash>` (https://fle.github.io/git-tip-keep-your-branch-clean-with-fixup-and-autosquash.html)
[status]
showUntrackedFiles = all
[diff]
algorithm = histogram # https://luppeng.wordpress.com/2020/10/10/when-to-use-each-of-the-git-diff-algorithms/
indentHeuristic = true
wordRegex = [A-Z][a-z]*|[a-z]+|[^[:space:]] # see camel case as separate words
colorMoved = zebra
; external = difft
; [diff "scala"]
; xfuncname = ^\\s*(.*(def|object|class|trait) .*)$
;
; [diff "markdown"]
; xfuncname = "^#+.*$"
[commit]
verbose = true # show diff in editor when committing
[apply]
ignoreWhitespace = change # do not produce whitespace conflicts
[alias]
st = status
co = checkout
cob = checkout -b
cot = "!TEMP=$(mktemp -d); f() { git worktree add \"$TEMP\" \"$1\" && git worktree list && bash -c \"cd '$TEMP'; echo 'When you are done, run git worktree prune $TEMP or exit the shell'; zsh\"; git worktree remove \"$TEMP\"; git worktree list; }; f" # checkout branch in temporary directory
ci = commit
amend = commit --amend
unstage = reset HEAD
prev = reset HEAD~1
fixup = !zsh -ic 'git commit --fixup $(git-select-commit)'
ignore = "!cd -- ${GIT_PREFIX:-.}; f() { echo \"$1\" >> .gitignore; }; f" # add to .gitignore in current directory
cl = clone
br = branch
; brr = branch -r
lg = log --pretty=format:'%Cred%h %C(reset)%C(dim)%ad%x08%x08%x08%x08%x08%x08%x08%x08%x08%Creset%C(blue) %an %Creset%s%C(yellow)%d %Cgreen(%ar)%Creset' --abbrev-commit --date=iso --graph --date-order
lga = log --branches --remotes --tags --full-history --graph --pretty=format:'%C(yellow)%d %Cred%h %C(reset)%C(blue)%an %C(reset)%s %Cgreen(%ar)%C(reset)'
df = diff --color-words='[A-Z][a-z]*|[a-z]+|[^[:space:]]' --irreversible-delete --find-copies-harder --find-copies --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-blank-lines --inter-hunk-context=2
dfs = df --staged
sdf = show --color-words
p = push
pf = push --force-with-lease
peng = push --force-with-lease
up = pull --rebase --autostash # somehow git does not pick these up from the config automatically anymore
u = up
f = fetch
fa = fetch --all
po = !git push --set-upstream origin \"$(git rev-parse --abbrev-ref HEAD)\" # push current branch to origin
dbr = "!f() { git branch -D $1; git push origin :$1;}; f" # delete local and remote branch
dtag = "!f() { git tag -d $1; git push origin :$1;}; f" # delete local and remote tag
wip = "!git add -A; git commit --message=\"WIP: `git diff --name-only --staged | xargs -L 1 basename | paste -sd \",\"`\""
wipbr = "!f() { git cob $1; git wip; git po;}; f" # commit and push everything on a new branch
prc = "!f() { ! git diff --staged --quiet && git diff --color-words --staged | cat && git diff --staged --stat | cat && read -p \"Commit Message: \" -r msg && git cob \"${1:-$(echo $msg | sed -E 's/[^a-zA-Z0-9]+/-/g')-fdietze-$(date -I)}\" && git commit --message \"$msg\" && gh pr create --title \"$msg\" --fill ;}; f"
prm = "!f() { ! git diff --staged --quiet && echo -n \"Commit Message: \" && read -r msg && git cob \"${1:-$(echo $msg | sed -E 's/[^a-zA-Z0-9]+/-/g')-fdietze-$(date -I)}\" && git commit --message \"$msg\" && gh pr create --title \"$msg\" --fill -l=\"ready-to-merge-squash\" ;}; f"
prd = "!f() { ! git diff --staged --quiet && echo -n \"Commit Message: \" && read -r msg && git cob \"${1:-$(echo $msg | sed -E 's/[^a-zA-Z0-9]+/-/g')-fdietze-$(date -I)}\" && git commit --message \"$msg\" && gh pr create --title \"$msg\" --fill --draft ;}; f"
prune-local = "!git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == \"[gone]\" {sub(\"refs/heads/\", \"\", $1); print $1}'); do (echo -n \"DELETE $branch? [y/N]: \"; read -r answer; [[ \"$answer\" =~ ^(y|Y) ]]) && git branch -D $branch; done"
prune-local-force = "!git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == \"[gone]\" {sub(\"refs/heads/\", \"\", $1); print $1}'); do git branch -D $branch; done"
ss = stash save --include-untracked
sski = stash save --include-untracked --keep-index
sp = stash pop
rb = rebase
rbm = rebase main
rbom = rebase origin/main
rba = rebase --abort
rbs = rebase --skip
rbc = rebase --continue
rbi = rebase -i
rbim = rebase -i main
rbiom = rebase -i origin/main
m = merge
ma = merge --abort
ms = merge --skip
mc = merge --continue
cp = cherry-pick
cpa = cherry-pick --abort
cps = cherry-pick --skip
cpc = cherry-pick --continue
[color "status"]
added = green
changed = yellow
untracked = blue
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
[core]
excludesfile = /home/felix/.config/git/ignore