-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitconfig
199 lines (199 loc) · 8.98 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
# This is Git's per-user configuration file.
#
# TODO: Look into splitting up personal and work specific configurations. See:
# - https://medium.com/@eduardosilva_94960/git-tips-simplify-multi-identity-management-with-includeif-8a4c9bcc9eb
# - https://gist.github.com/Icaruk/f024a18093dc28ec1588cfb90efc32f7
# - https://stackoverflow.com/questions/61543355/git-includeif-for-personal-and-work-profiles-doesnt-work
#
# TODO: Look into splitting up platform specific configurations. See:
# - https://medium.com/doing-things-right/platform-specific-gitconfigs-and-the-wonderful-includeif-7376cd44994d
#
# TODO: Go through the following:
# - https://jvns.ca/blog/2024/02/16/popular-git-config-options/
#
# TODO: Once difftastic has better github/delta-like background highlighting and
# 24-bit color support, consider using it over git-delta. See:
# - https://github.com/Wilfred/difftastic/issues/265
# - https://github.com/Wilfred/difftastic/issues/275
# - https://github.com/Wilfred/difftastic/pull/286
# - https://github.com/Wilfred/difftastic/issues/613
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = auto
pager = true
[user]
name = PratikBhusal
email = [email protected]
[core]
autocrlf = input
editor = nvim
pager = delta
[include]
path = ~/.config/delta/themes.gitconfig
# TODO: Toy around with `diff.colormoved`. See:
# - https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---color-movedltmodegt
[diff]
tool = nvimdiff
# Improve upon the default greedy algorithm for code changes. See:
# - https://luppeng.wordpress.com/2020/10/10/when-to-use-each-of-the-git-diff-algorithms
# - https://link.springer.com/article/10.1007/s10664-019-09772-z
algorithm = histogram
[commit]
verbose = true
# [merge]
# ff = no
# git log --exclude=refs/remotes/\* --all --oneline --graph
[alias]
switch-interactive = ! git branch | grep -v "^*" | fzf --height=~100% | xargs git checkout
diffremote = ! git diff origin/"$(git branch --show-current)"
localloggraph = log --exclude=refs/remotes/* --all --oneline --graph
localloggraphfrommain = log --exclude=refs/remotes/* --all --oneline --graph origin/main~..
changes-since-main = log -p --reverse origin/main..
cane= commit --amend --no-edit
# uso == (git add) update staged only
uso = ! git diff --cached --name-only --diff-filter=ad | xargs git add -u
# Make it a bit more explicit and safe that you want to force push changes
push--force = push --force-with-lease --force-if-includes
rename-remote-branch = "!f() { : git push ; \
if [ $# -ne 3 ]; then \
echo 'Rationale : Rename a branch on the server without checking it out.'; \
echo 'Usage : git rename-remote <remote> <old name> <new name>'; \
echo 'Example : git rename-remote origin master main'; \
return 1; \
fi; \
git push $1 $1/$2:refs/heads/$3 :$2; \
}; f"
rename-local-and-remote-branch = "!f() { : git branch ; \
if [ $# -ne 2 ]; then \
echo 'Rationale : Rename current local and and remote branch name without checking it out.'; \
echo 'Usage : git cbrlr <remote> <new name>'; \
echo 'Example : git rename-local-and-remote-branch origin main'; \
return 1; \
fi; \
\
_old_branch_name=\"$(git branch --show-current)\"; \
\
git branch -m $2 \
&& git push $1 $1/$_old_branch_name:refs/heads/$2 :$_old_branch_name \
&& git branch -u $1/$2; \
}; f"
[init]
defaultBranch = main
[difftool "nvimdiff"]
cmd = "nvim -d \"$LOCAL\" \"$REMOTE\""
[interactive]
diffFilter = delta --color-only
[delta]
features = darkokai
[credential]
helper = git-credential-manager
[merge]
# See:
# - https://stackoverflow.com/questions/71252026/how-do-i-use-zealous-diff3-with-git-and-what-are-the-pros-and-cons
# - https://ductile.systems/zdiff3/
conflictStyle = zdiff3
[push]
# See:
# - https://git-scm.com/docs/git-config/#Documentation/git-config.txt-pushautoSetupRemote
autoSetupRemote = true
# Make `git push --force` more safe. If local commits include the latest
# changes of the remote branch to which you are pushing (meaning the current
# commits of the remote branch are found within your local commits), then
# the git push operation will proceed. If the remote repository's commits
# are not present locally, this forced push operation is denied.
#
# In other words:
# - Ensures that local commits encompass the remote changes.
# - Prevents accidental overwriting of changes in the remote repository.
# - Avoids critical errors, especially when multiple people are working on
# the same repository.
#
# See:
# - https://vladimirzdrazil.com/til/git/git-force-if-includes
# - https://medium.yemreak.com/safe-pushing-with-git-3714ffec9ac1
# - https://stackoverflow.com/questions/65837109/when-should-i-use-git-push-force-if-includes
useForceIfIncludes = true
[branch]
# Sort branches by last committed in ascending order ie branch with newest
# commit is at the bottom.
sort = committerdate
[rebase]
# Improve upon the usual stacked branch workflow by automatically updating
# refs when rebasing.
#
# See:
# - https://andrewlock.net/working-with-stacked-branches-in-git-is-easier-with-update-refs
# - https://stacking.dev
# - https://www.codetinkerer.com/2023/10/01/stacked-branches-with-vanilla-git.html
#
# TODO: Look into git-branchless:
# - https://github.com/arxanas/git-branchless
updateRefs = true
[fetch]
# If a branch/tag no longer exists in the remote repository, remove the
# local reference when calling `git fetch` by default
#
# See the following to delete local branches when the remote no longer
# exists:
# - https://stackoverflow.com/questions/13064613/how-to-prune-local-tracking-branches-that-do-not-exist-on-remote-anymore
prune = true
prunetags = true
[help]
# If you mistyped a command, git tries to figure out what you mean.
#
# If set to an integer, git tries to run the auto-corrected command after a
# certain period of waiting. If the value is an integer ie 1, it will wait
# for 0.1 seconds. If it is 10, it will wait for 1 second.
#
# If set to `prompt`, git prompts if you want to run the autocorrect
# command. Pressing `y` and enter runs the autocorrected command.
#
# use Ctrl-c to always cancel running the autocorrected command
autocorrect = prompt
[url "[email protected]:"]
# When running:
# ```
# git clone gh:PratikBhusal/dotfiles.git
# ```
# treat it as if you actually ran:
# ```
# git clone [email protected]:PratikBhusal/dotfiles.git
# ```
insteadOf = "gh:"
# insteadOf = "https://github.com/"
[url "[email protected]:"]
# When running:
# ```
# git clone gl:PratikBhusal/dotfiles.git
# ```
# treat it as if you actually ran:
# ```
# git clone [email protected]:PratikBhusal/dotfiles.git
# ```
insteadOf = "gl:"
# insteadOf = "https://gitlab.com/"
[url "[email protected]:PratikBhusal"]
# For your git repositories, always use ssh for pushing.
pushInsteadOf = "https://github.com/PratikBhusal"
# After including all default git config settings, include Path of
# Exile-specific settings. We need the trailing slash for subdirectories to
# work.
#
# Eg:
# - user.name
# - user.email
[includeIf "gitdir:~/workplace/path-of-exile/"]
path = ~/workplace/path-of-exile/.path-of-exile.gitconfig
# After including all default git config settings, include work-specific
# settings. We need the trailing slash for subdirectories to work.
#
# Eg:
# - user.name
# - user.email
#
# Always make sure this include is the very last line of the .gitconfig file!
[includeIf "gitdir:~/workplace/work/"]
path = ~/workplace/work/.work.gitconfig