-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitconfig
210 lines (184 loc) · 12.6 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
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
[user]
name = Janick Martinez Esturo
email = janick.martinez.esturo@gmail.com
signingkey = A85C4836
[color]
ui = auto
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[color "branch"]
upstream = cyan # blue on black is hard to read in git branch -vv: use cyan instead
[core]
excludesfile = ~/.gitignore
whitespace = -trailing-space # don't consider trailing space change as a cause for merge conflicts
[alias]
# shortcuts
co = checkout
br = branch
brDlast = branch -D @{-1} # deletes last checked out branch
# show additional branch-specific information
bb = !git for-each-ref --color --sort=-committerdate --format='%(color:green)%(upstream:trackshort)\t%(color:red)%(ahead-behind:HEAD)\t%(color:blue)%(refname:short)\t%(color:yellow)%(committerdate:relative)\t%(color:default)\t%(describe)' refs/heads | sed 's/ /\t/' | column --separator='\t' --output-separator=' ' --table --table-columns='State,Ahead,Behind,Branch,Last Commit,Description'
ci = commit -v
cif = commit -v --fixup
st = status
sst = submodule status --recursive
su = submodule update --recursive
sur = submodule update --recursive --remote
sco = !git checkout $1 && git su && :
f = fetch
p = fetch
ls = ls-files
df = diff
dc = diff --cached
lfsco = !git lfs fetch origin origin/$1 && git co $1 && :
# force push with lease (check commits that are overwritten to not differ asynchronously from local ones)
lease = push --force-with-lease
# place all submodules on their respective branch specified in .gitmodules
sm-co-trackb = "!git submodule foreach -q --recursive 'branch="$(git config -f $toplevel/.gitmodules submodule.$name.branch)"; [ ! -z "$branch" ] && echo $branch @ $name && git co $branch || echo NONE @ $name'"
sm-co-trackb-p = "!git submodule foreach -q --recursive 'branch="$(git config -f $toplevel/.gitmodules submodule.$name.branch)"; [ ! -z "$branch" ] && echo $branch @ $name && git co $branch && git fetch -a -p && git pull || echo NONE @ $name'"
# git sm-diff will diff the master repo *and* its submodules
sm-diff = "!git diff && git submodule foreach 'git diff' "
# git sm-push will ask to push also submodules
sm-push = push --recurse-submodules=on-demand
# (graph) logs
l = log --graph --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset% %m %C(bold white)%s%Creset% %C(bold magenta)%N%Creset %Cgreen(%cr)%Creset %C(bold blue)<%an>%Creset' --date=relative
la = log --graph --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset% %m %C(bold white)%s%Creset% %C(bold magenta)%N%Creset %Cgreen(%cr)%Creset %C(bold blue)<%an>%Creset' --date=relative --all
las = log --graph --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset% %m %C(bold white)%s%Creset% %C(bold magenta)%N%Creset %Cgreen(%cr)%Creset %C(bold blue)<%an>%Creset' --date=relative --all --stat
lan = log --graph --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset% %m %C(bold white)%s%Creset% %C(bold magenta)%N%Creset %Cgreen(%cr)%Creset %C(bold blue)<%an>%Creset' --date=relative --all --name-status
ll = log --graph --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset% %m %C(bold white)%s%Creset%+b %C(bold magenta)%N%Creset %Cgreen(%cr)%Creset %C(bold blue)<%an>%Creset' --date=relative
lla = log --graph --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset% %m %C(bold white)%s%Creset%+b %C(bold magenta)%N%Creset %Cgreen(%cr)%Creset %C(bold blue)<%an>%Creset' --date=relative --all
llas = log --graph --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset% %m %C(bold white)%s%Creset%+b %C(bold magenta)%N%Creset %Cgreen(%cr)%Creset %C(bold blue)<%an>%Creset%n' --date=relative --all --stat
llan = log --graph --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset% %m %C(bold white)%s%Creset%+b %C(bold magenta)%N%Creset %Cgreen(%cr)%Creset %C(bold blue)<%an>%Creset%n' --date=relative --all --name-status
last = log -1 HEAD
# show ignored files
ign = ls-files -o -i --exclude-standard
# show the history of a file, with diffs
filelog = log -u
fl = log -u
# file-level ignore
assume = update-index --assume-unchanged
unassume = update-index --no-assume-unchanged
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
# snapshot stash
snapshot = !git stash save "snapshot: $(date)" && git stash apply "stash@{0}"
# revert changes
unstage = reset HEAD --
# merge file selection
ours = "!f() { git checkout --ours $@ && git add $@; }; f"
theirs = "!f() { git checkout --theirs $@ && git add $@; }; f"
# stash regex show / apply
sshow = "!f() { git stash show stash^{/$*} -p; }; f"
sapply = "!f() { git stash apply stash^{/$*}; }; f"
# Publish the current branch by pushing it to the remote "origin", and setting the current branch to track the upstream branch
publish = !"git push -u origin $(git branch-name)"
# Unpublish the current branch by deleting the remote version of the current branch
unpublish = !"git push origin :$(git branch-name)"
# Get the current branch name
branch-name = !"git rev-parse --abbrev-ref HEAD"
# Get the top level directory, regardless of what subdirectory we're in
root = ! pwd
# Execute shell scripts. Git always runs scripts in the top directory. For example "git exec pwd" will always show you the top directory
exec = ! exec
# Revert a single file of a commit. usage: git-revert-file <sha1> <file>
revert-file = ! git-revert-file.sh
# Get recent stuff for standup meetings
scrum = "!f() { git log --since=\"$1 days ago\" --author='Janick Martinez Esturo' --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset% %m %C(bold white)%s%Creset%+b %C(bold magenta)%N%Creset%Cgreen(%cr) %C(bold blue)<%an>%Creset' --branches; }; f"
# Difftool
showtool = "!f() { git difftool $1^ $1; }; f" # show a commit using difftool
added = difftool --cached # show staged changes using difftool
# Prune - delete local branches that were deleted from the remote
prune = fetch --prune
# Undo - reset before last commit
undo = reset --soft HEAD^
# Stash-all - stash also untracked files
stash-all = stash save --include-untracked
# Stash only staged changes
stash-staged = stash push -S
# Determine the merge commit associated with a commit
find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'"
show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'"
[branch]
autosetuprebase = always # perform rebase instead of merges on 'git pull'
[diff]
algorithm = patience # semantically more meaningful diffs
mnemonicPrefix = true # use better, descriptive initials (c, i, w) instead of a/b
renames = true # show renames/moves as such
wordRegex = . # when using --word-diff, assume --word-diff-regex=.
submodule = diff # display submodule-related information (diff listing)
indentHeuristic = true # try to detect more meaningful change boundaries
compactionHeuristic = true # try to compact changes to more meaningful blocks
tool = icdiff # install via `pip3 install --user icdiff`
guitool = meld # gui-based difftool if requested
[difftool]
prompt = false
[difftool "icdiff"]
cmd = icdiff --line-numbers $LOCAL $REMOTE
[difftool "meld"]
cmd = meld $LOCAL $REMOTE
[pager]
difftool = true
branch = false
[push]
default = upstream # default push should only push the current branch
# to its push target, regardless of its remote name
recurseSubmodules = on-demand # also push changes of submodules
followTags = true # also push tags
[fetch]
prune = true # prune local branches and tags that were deleted remotely
recurseSubmodules = on-demand # auto-fetch submodule changes (sadly, won't auto-update)
[pull]
rebase = merges # preserves merge commits on rebase initiated by pull
[rebase]
autosquash = true # allways autosquash fixup commits
instructionFormat = [%an @ %ar] %s
autostash = true # stash and reapply dirty worktree on rebase
[mergetool]
keepBackup = false # clean up backup files created by merge tools on tool exit
keepTemporaries = false # clean up temp files created by merge tools on tool exit
writeToTemp = true # put the temp files in a dedicated dir anyway
[clangFormat]
binary = clang-format-3.9
style = file
[credential]
# Compile instructions: http://stackoverflow.com/a/13390889/481320
helper = /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
[merge]
tool = meld
conflictStyle = diff3 # display common-ancestor blocks in conflict hunks
ff = only # only allow ff merges by default, use git merge --ff to force a merge commit
[tag]
sort = version:refname # sort tags as version numbers whenever applicable, so 1.10.2 is AFTER 1.2.0
[log]
abbrevCommit = true # use abbrev SHAs whenever possible/relevant instead of full 40 chars
follow = true # automatically --follow when given a single path
[commit]
gpgSign = true
[grep]
extendedRegexp = true # consider most regexes to be ERE
[versionsort]
prereleaseSuffix = -pre
prereleaseSuffix = .pre
prereleaseSuffix = -beta
prereleaseSuffix = .beta
prereleaseSuffix = -rc
prereleaseSuffix = .rc
[include]
path = ~/.gitconfig_private # private git configuration
[submodule]
fetchJobs = 4 # fetch submodules in parallel jobs
[stash]
showPatch = true # show diff on `git stash show`
[rerere]
enabled = false
[http]
cookiefile = /home/janickm/.gitcookies
[merge "bazel-lockfile-merge"]
name = Merge driver for the Bazel lockfile (MODULE.bazel.lock)
driver = "jq -s '# Merges an arbitrary number of MODULE.bazel.lock files.\n#\n# Input: an array of MODULE.bazel.lock JSON objects (as produced by `jq -s`).\n# Output: a single MODULE.bazel.lock JSON object.\n#\n# This script assumes that all files are valid JSON and have a numeric\n# \"lockFileVersion\" field. It will not fail on any such files, but only\n# preserves information for files with a version of 10 or higher.\n#\n# The first file is considered to be the base when deciding which values to\n# keep in case of conflicts.\n\n# Like unique, but preserves the order of the first occurrence of each element.\ndef stable_unique:\n reduce .[] as $item ([]; if index($item) == null then . + [$item] else . end);\n\n# Given an array of objects, shallowly merges the result of applying f to each\n# object into a single object, with a few special properties:\n# 1. Values are uniquified before merging and then merged with last-wins\n# semantics. Assuming that the first value is the base, this ensures that\n# later occurrences of the base value do not override other values. For\n# example, when this is called with B A1 A2 and A1 contains changes to a\n# field but A2 does not (compared to B), the changes in A1 will be preserved.\n# 2. Object keys on the top level are sorted lexicographically after merging,\n# but are additionally split on \":\". This ensures that module extension IDs,\n# which start with labels, sort as strings in the same way as they due as\n# structured objects in Bazel (that is, //python/extensions:python.bzl\n# sorts before //python/extensions/private:internal_deps.bzl).\ndef shallow_merge(f):\n map(f) | stable_unique | add | to_entries | sort_by(.key | split(\":\")) | from_entries;\n\n(\n # Ignore all MODULE.bazel.lock files that do not have the maximum\n # lockFileVersion.\n (map(.lockFileVersion) | max) as $maxVersion\n | map(select(.lockFileVersion == $maxVersion))\n | {\n lockFileVersion: $maxVersion,\n registryFileHashes: shallow_merge(.registryFileHashes),\n selectedYankedVersions: shallow_merge(.selectedYankedVersions),\n # Group extension results by extension ID across all lockfiles with\n # shallowly merged factors map, then shallowly merge the results.\n moduleExtensions: (map(.moduleExtensions | to_entries)\n | flatten\n | group_by(.key)\n | shallow_merge({(.[0].key): shallow_merge(.value)}))\n }\n)? //\n # We get here if the lockfiles with the highest lockFileVersion could not be\n # processed, for example because all lockfiles have lockFileVersion < 10.\n # In this case Bazel 7.2.0+ would ignore all lockfiles, so we might as well\n # return the first lockfile for the proper \"mismatched version\" error\n # message.\n .[0]' -- %O %A %B > %A.jq_tmp && mv %A.jq_tmp %A"