aboutsummaryrefslogtreecommitdiffhomepage
path: root/.config/git/config
blob: 555701c7b2a576053ba1ea6988dccf0e05059b28 (plain)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
[core]
    editor = nvim
    pager = "less --tabs=4"
    commentchar = ";"
    quotepath = false

[advice]
    detachedhead = false
    skippedcherrypicks = false

[help]
    autocorrect = prompt

[color]
    ui = true

[column]
    ui = auto

[tag]
    sort = version:refname

[commit]
    status = false

[fetch]
    prune = true
    prunetags = true
    all = true

[pull]
    rebase = true

[merge]
    tool = vimdiff
    ff = false
    conflictstyle = zdiff3

[mergetool "vimdiff"]
    cmd = "__fn() { \
        if [ -z \"$BASE\" ]; then \
            nvim -d -c 'wincmd l' \"$LOCAL\" \"$MERGED\" \"$REMOTE\"; \
        else \
            nvim -d -c '4wincmd w | wincmd J | diffoff' \"$LOCAL\" \"$BASE\" \"$REMOTE\" \"$MERGED\"; \
        fi; \
    }; __fn"

[rebase]
    abbreviatecommands = true
    autosquash = true
    autostash = true
    updaterefs = true

[rerere]
    enabled = true
    autoupdate = true

[diff]
    algorithm = histogram
    colormoved = plain
    mnemonicprefix = true
    renames = true
    tool = vimdiff

[difftool "vimdiff"]
    cmd = "nvim -R -d -c 'wincmd l' -c 'cd $GIT_PREFIX' \"$LOCAL\" \"$REMOTE\""

[init]
    defaultbranch = main

[blame]
    coloring = repeatedLines

[mergetool]
    keepbackup = false

[credential "https://github.com"]
    helper = !gh auth git-credential

[credential "https://gist.github.com"]
    helper = !gh auth git-credential

[filter "lfs"]
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
    process = git-lfs filter-process
    required = true

[alias]
    a = add
    ap = add -p
    b = branch
    current-branch = rev-parse --abbrev-ref HEAD
    c = commit
    fetch1 = fetch --depth=1
    fixup = commit --fixup
    amend = commit --amend --no-edit
    clone1 = clone --depth=1
    swc = switch -c
    swm = "!__fn() { \
        if git rev-parse --verify --quiet main > /dev/null 2>&1; then \
            git switch main \"$@\"; \
        elif git rev-parse --verify --quiet origin/main > /dev/null 2>&1; then \
            git switch -d origin/main \"$@\"; \
        elif git rev-parse --verify --quiet master > /dev/null 2>&1; then \
            git switch master \"$@\"; \
        elif git rev-parse --verify --quiet origin/master > /dev/null 2>&1; then \
            git switch -d origin/master \"$@\"; \
        else \
            echo 'error: no branch found' >&2; \
        fi; \
    }; __fn"
    swd = "!__fn() { \
        if git rev-parse --verify --quiet develop > /dev/null 2>&1; then \
            git switch develop \"$@\"; \
        elif git rev-parse --verify --quiet origin/develop > /dev/null 2>&1; then \
            git switch -d origin/develop \"$@\"; \
        else \
            echo 'error: no branch found' >&2; \
        fi; \
    }; __fn"
    d = diff
    dc = diff --cached
    g = grep
    gf = grep --name-only
    s = status --short
    wip = commit -a -m "wip"
    cwip = commit -m "wip"
    swip = stash save "wip"
    sswip = swip
    ss = stash save
    ssl = stash list
    ssa = stash apply
    ssd = stash drop
    ssp = stash pop
    tags = tag
    last = log --pretty=fuller -1
    l = "!__fn() { \
        local last_merge_commit=\"$(git last-merge-commit)\"; \
        if [ -n \"$last_merge_commit\" ]; then \
            git log --oneline --boundary \"$last_merge_commit\".. \"$@\"; \
        else \
            git log --oneline -n 10 \"$@\"; \
        fi; \
    }; __fn"
    ll = log --oneline
    logf = log --pretty=fuller
    graph = log --oneline --graph
    r = rebase
    ri = rebase -i
    rid = rebase -i develop
    rc = "!GIT_EDITOR=true git rebase --continue"
    re = restore
    rep = restore -p
    m = "!__fn() { \
        if [ \"$1\" = --abort ]; then \
            git merge --abort; \
        else \
            git merge --no-edit \"$@\"; \
        fi; \
    }; __fn"
    mc = "!GIT_EDITOR=true git merge --continue"
    mm = mergetool
    pullu = pull upstream HEAD --ff
    pullo = pull origin HEAD --ff
    pusho = push origin HEAD
    cpick = cherry-pick
    cpickc = "!GIT_EDITOR=true git cherry-pick --continue"
    empty = commit --allow-empty
    last-merge-commit = "!git rev-list --abbrev-commit --merges HEAD | head -n 1"
    config-user = "!__fn() { \
        if [ \"$1\" = nsfisis ]; then \
            git config user.name nsfisis && git config user.email nsfisis@gmail.com; \
        elif [ \"$1\" = \"\" ]; then \
            echo \"usage: git config-user <user>\" >&2; \
        else \
            echo \"unknown user: $1\" >&2; \
        fi; \
    }; __fn"
    setup-hooks = "!cp ~/dotfiles/githooks/* \"$(git rev-parse --show-toplevel)/.git/hooks\""
    init-empty = "!__fn() { \
        if [ \"$1\" = \"\" ]; then \
            echo \"usage: git init-empty <user>\" >&2; \
        else \
            git init . && git config-user \"$1\" && git empty -m \"<empty>\"; \
        fi; \
    }; __fn"
    ignore = "!__fn() { \
        if [ \"$1\" = \"\" ]; then \
            echo \"usage: git ignore <pattern>\" >&2; \
        else \
            echo \"$1\" >> \"$(git rev-parse --git-dir)/info/exclude\"; \
        fi; \
    }; __fn"
    sync-upstream = "!__fn() { \
        if [ \"$1\" = \"\" ]; then \
            local branch=\"$(git current-branch)\"; \
        else \
            local branch=\"$1\"; \
        fi; \
        if git rev-parse --verify --quiet \"origin/$branch\" > /dev/null 2>&1 && \
           git rev-parse --verify --quiet \"upstream/$branch\" > /dev/null 2>&1; then \
            git branch --force \"$branch\" \"upstream/$branch\" && \
            git push --force-with-lease origin \"$branch\"; \
        else \
            echo \"error: branch '$branch' not found on both origin and upstream\" >&2; \
            exit 1; \
        fi; \
    }; __fn"
    backup-branch = "!__fn() { \
        if [ \"$1\" = \"\" ]; then \
            local branch=\"$(git current-branch)\"; \
        else \
            local branch=\"$1\"; \
        fi; \
        local sha=$(git rev-parse --short \"$branch\"); \
        local backup_branch=\"bak/$branch/$sha\"; \
        if ! git rev-parse --verify --quiet \"$backup_branch\" > /dev/null 2>&1; then \
            git branch \"$backup_branch\" \"$branch\"; \
        fi; \
    }; __fn"
    squash-onto = "!__fn() { \
        if [ \"$1\" = \"\" ]; then \
            echo \"usage: git squash-onto <base-ref>\" >&2; \
            exit 1; \
        fi; \
        local base_ref=\"$1\"; \
        git reset --soft \"$base_ref\" && \
        git commit --edit -m \"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; \
    }; __fn"