]> git.phdru.name Git - dotfiles.git/blob - .gitconfig
e38baa0e704ab3c020dd017f1a57e768c5f791a4
[dotfiles.git] / .gitconfig
1 [alias]
2 # I copied some aliases from http://gitalias.com/ and other sources.
3 # Some I've added to gitalias. Some are mine.
4
5   # One letter alias for our most frequent commands.
6   a = add
7   b = branch
8   c = commit
9   d = diff
10   f = fetch
11   g = grep
12   l = log
13   m = merge
14   o = checkout
15   p = pull
16   r = remote
17   s = status
18   w = whatchanged
19
20   ### add ###
21
22   aa = add --all
23
24   ap = add --patch
25
26   au = add --update
27
28   ### branch ###
29
30   be = branch --edit-description
31
32   bm = branch --merged
33
34   bnm = branch --no-merged
35
36   ### commit ###
37
38   cm = commit --message
39
40   ### checkout ###
41
42   co = checkout
43
44   ### cherry-pick ###
45
46   chp = cherry-pick
47
48   ### diff ###
49
50   # diff - show changes not yet staged
51   dc = diff --cached
52
53   # diff - changes about to be commited
54   ds = diff --staged
55
56   # diff - show changes but by word, not line
57   dw = diff --word-diff
58
59   ### rebase ###
60
61   rb = rebase
62
63   rba = rebase --abort
64
65   rbc = rebase --continue
66
67   rbs = rebase --skip
68
69   # See https://blog.filippo.io/git-fixup-amending-an-older-commit/
70   # This is a slightly modified version
71   fixup = "!f() { TARGET=$(git rev-parse \"$1\"); git commit --fixup=$TARGET && GIT_EDITOR=true exec git rebase --interactive --autostash --autosquash $TARGET~; }; f"
72
73   ### remote ###
74
75   rs = remote show
76
77   ru = remote update
78
79   rp = remote prune
80
81   incoming = !git remote update --prune; exec git log ..@{upstream}
82   outgoing = log @{upstream}..
83
84   # Push to all remotes
85   push-to-all-remotes = !git remote | xargs -I% -n1 git push %
86
87   ### show-branch ###
88
89   # show-branch - print a list of branches and their commits.
90   sb = show-branch
91
92   ### status ###
93
94   ss = status --short
95
96   ssb = status --short --branch
97
98   aliases = "!git config --get-regexp '^alias\\.' | cut -c7- | sed 's/ / = /'"
99
100   add-alias = "!f() { [ $# = 3 ] && git config $1 alias.\"$2\" \"$3\" && return 0 || echo \"Usage: git add-(local|global)-alias <new alias> <original command>\" >&2 && return 1; }; f"
101   add-global-alias = "!exec git add-alias --global"
102   add-local-alias = "!exec git add-alias --local"
103
104   # Last tag in the current branch
105   lasttag = describe --tags --abbrev=0
106
107   # Latest annotated tag in all branches
108   lasttagged = !exec git describe --tags `exec git rev-list --tags --max-count=1`
109
110   # List all tags
111   tags = tag --list -n1
112
113   # Find text in any commit ever
114   grep-all = !"f() { git rev-list --all | xargs git grep \"$@\"; }; f"
115
116   # Edit all files of the given type
117   edit-cached = !"f() { git ls-files --cached | sort -u ; }; exec `exec git var GIT_EDITOR` `f`"
118   edit-deleted = !"f() { git ls-files --deleted | sort -u ; }; exec `exec git var GIT_EDITOR` `f`"
119   edit-others = !"f() { git ls-files --others | sort -u ; }; exec `exec git var GIT_EDITOR` `f`"
120   edit-ignored = !"f() { git ls-files --ignored | sort -u ; }; exec `exec git var GIT_EDITOR` `f`"
121   edit-killed = !"f() { git ls-files --killed | sort -u ; }; exec `exec git var GIT_EDITOR` `f`"
122   edit-modified = !"f() { git ls-files --modified | sort -u ; }; exec `exec git var GIT_EDITOR` `f`"
123   edit-stage = !"f() { git ls-files --stage | cut -f2 | sort -u ; }; exec `exec git var GIT_EDITOR` `f`"
124
125   # Editing and adding conflicted files: when we get many merge conflicts
126   # and want to quickly solve them using an editor, then add the  files.
127   edit-unmerged = !"f() { git ls-files --unmerged | cut -f2 | sort -u ; }; exec `exec git var GIT_EDITOR` `f`"
128   add-unmerged = !"f() { git ls-files --unmerged | cut -f2 | sort -u ; }; exec git add `f`"
129
130   # Get the current branch name
131   branch-name = rev-parse --abbrev-ref HEAD
132
133   assume   = update-index --assume-unchanged
134   unassume = update-index --no-assume-unchanged
135   # assume-all = "!git st -s | awk {'print $2'} | xargs git assume"
136   unassume-all = "!git assumed | xargs git update-index --no-assume-unchanged"
137   assumed  = !"git ls-files -v | grep ^h | cut -c 3-"
138
139   stashes = stash list
140
141         branches = branch --all
142         ca = commit --all
143         cv = commit --verbose
144         cav = commit --all --verbose
145         cane = commit --amend --no-edit
146         checkin = commit
147         ci = commit
148         cat = cat-file -p
149         dh = "!f() { git -c color.diff=always diff \"$@\" | perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight | less; }; f"
150         dir = rev-parse --git-dir
151         dump = cat-file -p
152         file = cat-file -t
153         type = cat-file -t
154         ff = merge --ff-only
155         #git = !exec git
156         l1 = log --decorate --oneline
157         l5 = log --decorate -5
158         ld = log --decorate
159         lg = log --decorate --graph
160         lg1 = log --decorate --graph --oneline
161         lg5 = log --decorate --graph -5
162         lr = log --decorate --reverse
163         lr1 = log --decorate --reverse --oneline
164         lr5 = log --decorate --reverse -5
165         null-merge = merge --strategy=ours
166         rbi123 = "!f() { exec git rebase --interactive --autostash $1 $2 ${3:-\"@{upstream\\}\"}; }; f"
167         rbi = !exec git rbi123 '' ''
168         rbia = !exec git rbi123 --autosquash ''
169         rbiap = !exec git rbi123 --autosquash --preserve-merges
170         rbip = !exec git rbi123 '' --preserve-merges
171         remotes = remote --verbose
172         #root = !exec pwd
173         root = rev-parse --show-toplevel
174         status = status --no-short
175         st = status --short
176         stb = status --short --branch
177         sd = show --decorate
178         sw = show --word-diff --decorate
179         unstage = reset HEAD --
180
181         # Github: pull request, Gitlab: merge request
182         mpr = "!f() { git fetch ${2:-origin} refs/$3/$1/head:pr/$1 && if [ \"$4\" = checkout ]; then git checkout pr/$1; fi; }; f"
183         fetch-mr = "!f() { git mpr $1 ${2:-origin} merge-requests; }; f"
184         merge-request = "!f() { git mpr $1 ${2:-origin} merge-requests checkout; }; f"
185         fetch-pr = "!f() { git mpr $1 ${2:-origin} pull; }; f"
186         pull-request = "!f() { git mpr $1 ${2:-origin} pull checkout; }; f"
187         clean-pr = "!git checkout master ; git for-each-ref refs/heads/pr/* --format=\"%(refname)\" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"
188
189 [branch]
190         autosetuprebase = always
191
192 [color]
193         ui = auto
194
195 [diff]
196         indentHeuristic = true
197
198 [grep]
199         fallbackToNoIndex = true
200
201 [include]
202         path = ~/lib/config/git/light_bg
203
204 [init]
205         defaultBranch = master
206
207 [log]
208         abbrevCommit = true
209         #mailmap = true
210
211 [merge]
212         tool = vimdiff
213
214 #[mergetool "vimdiff3"]
215 # Don't forget to add -f for gvim
216 # 3 way diffs
217 #       cmd = vim -d \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\" -c \"wincmd J\"
218
219 [push]
220         default = simple
221         followTags = true
222         recurseSubmodules = check
223
224 [receive]
225         #denyCurrentBranch = updateInstead
226         denyDeleteCurrent = true
227         #denyDeletes = true
228         #denyNonFastForwards = true
229
230 #[tag]
231 #       sort = version:refname
232
233 [tar "tar.bz2"]
234         command = bzip2 -c
235 [tar "tar.xz"]
236         command = xz -c
237
238 #[transfer]
239 #       fsckObjects = true
240
241 [user]
242         signingKey = 6E080B70B6287B03
243
244 [web]
245         browser = webbrowser
246
247 [browser "webbrowser"]
248         cmd = webbrowser -n
249
250 [gui]
251         fontui = -family \"DejaVu Sans\" -size 18 -weight normal -slant roman -underline 0 -overstrike 0
252         fontdiff = -family \"DejaVu Sans Mono\" -size 18 -weight normal -slant roman -underline 0 -overstrike 0
253
254 # git:// protocol fixers
255 #[url "https://github.com/"]
256 #       insteadOf = "git://github.com/"
257 #[url "https://gist.github.com/"]
258 #       insteadOf = "git://gist.github.com/"
259 #[url "ssh://git@github.com/"]
260 #       insteadOf = "git://github.com/"
261 #[url "ssh://git@gist.github.com/"]
262 #       insteadOf = "git://gist.github.com/"
263 #[url "https://gitlab.com/"]
264 #       insteadOf = "git://gitlab.com/"
265 #[url "https://gist.gitlab.com/"]
266 #       insteadOf = "git://gist.gitlab.com/"
267 #[url "ssh://git@gitlab.com/"]
268 #       insteadOf = "git://gitlab.com/"
269 #[url "ssh://git@gist.gitlab.com/"]
270 #       insteadOf = "git://gist.gitlab.com/"
271
272 # Protocol changers
273 #[url "https://github.com/"]
274 #       insteadOf = ssh://github.com/
275 #       insteadOf = ssh://git@github.com/
276 #       insteadOf = git@github.com:
277
278 #[url "ssh://git@github.com/"]
279 #       insteadOf = https://github.com/
280
281 #[url "https://gitlab.com/"]
282 #       insteadOf = ssh://gitlab.com/
283 #       insteadOf = ssh://git@gitlab.com/
284 #       insteadOf = git@gitlab.com:
285
286 #[url "ssh://git@gitlab.com/"]
287 #       insteadOf = https://gitlab.com/