-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitconfig
253 lines (229 loc) · 10.8 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
[user]
email = [email protected]
name = Andrew Peacock
[core]
editor = nvim
whitespace = trailing-space,space-before-tab
pager = delta --line-numbers --dark
[diff]
tool = nvimdiff
[difftool]
tool = nvimdiff
[difftool "nvimdiff"]
cmd = "nvim -d \"$LOCAL\" \"$REMOTE\""
[credential]
helper = store
[delta]
side-by-side = false
;plus-style = "syntax #012800"
;minus-style = "syntax #340001"
plus-style = "syntax auto"
minus-style = "syntax auto"
;plus-emph-style = "syntax bold underline auto"
minus-emph-style = "syntax bold strike auto"
syntax-theme = Monokai Extended
file-style = "#53ba4a"
line-numbers-left-style = grey
line-numbers-right-style = white
line-numbers-minus-style = "#e00205"
line-numbers-plus-style = "#04a021"
file-modified-label = ⚙
navigate = true
;hyperlinks = true
line-numbers = true
zero-style = dim syntax
true-color = always
[interactive]
diffFilter = delta --color-only
[alias]
#### General ####
# Regular git log
lg = log --name-status
# Short/Summary git log for large repo log
ll = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
# Shortcut + verbose
fe = fetch -v
# Shortcut for status
st = status
# Updates submodules Note: Equivelant to "git submodule sync && git submodule update"?
updatesub = submodule update --recursive --init
# Force rename a file, normally case differences in git name to local name
mv = mv -f
# Push to origin HEAD with force.
submit = !"git fetch origin && git rebase origin/master --stat && git push origin +HEAD"
# Push to origin HEAD with force with no rebase
submit-norb = !"git fetch origin && git push origin +HEAD"
# Shortcut for ls-files
ls = ls-files -v
# List ignored files
ls-ignored = ls-files . --ignored --exclude-standard --others
#### Grep ####
# grep shortcut + enable Perl regex
g = grep --perl-regexp --line-number
# grep shortcut + enable Perl regex with match whole word only
gw = grep --perl-regexp --line-number --word-regexp
# grep including the history of the files
gh = !"f() { git rev-list --all | xargs git grep \"$@\"; }; f"
# Display the files (uniq) which the string matches by first greping, strip away the file name using the delimiter ':', then uniq
gu = !"f() { git grep -P \"$@\" | awk -F: \"{print "\\$1"}\" | uniq; }; f"
#### Stash Shortcuts ####
s = stash
sa = stash apply
sc = stash clear
sd = stash drop
sl = stash list --date=local
sp = stash pop
ss = stash show -p
# stash file
sf = stash push
# Abort a stash apply
saa = reset --merge
stash-continue = !"git restore --staged . && git stash drop"
# Apply the stash of the index
san = !"f() { git stash apply stash@{$1}; }; f"
#### Rebase Shortcuts ####
rb = rebase
rba = rebase --abort
rbc = rebase --continue
rbi = rebase --interactive
rbs = rebase --skip
#### Cherry Pick Shortcuts ####
cp = cherry-pick -x
cpa = cherry-pick --abort
cpc = cherry-pick --continue
cpi = cherry-pick --interactive
cps = cherry-pick --skip
#### Commitments ####
# Commit modified and deleted file changes. Brings up set text editor for message
co = !"git add -u && git commit"
# Commit modified and deleted file changes with the given commit message
co-m = !"f() { git add -u && git commit -m \"$@\"; }; f"
# Commit changes and ammend to last commit, resetting the date of the commit
co-am = !"git add -u && git commit --amend --no-edit --date=now"
# Commit changes and ammend to last commit + edit the commit message
co-am-ed = !"git add -u && git commit --amend --reset-author --date=now"
# Adds all untracked files
add-untracked = !"echo -e "a\n*\nq\n" | git add -i"
# Undo the last commit, making them uncommited changes
reset-h = reset HEAD~
# Set the file to the commit before the last one
uncommit = !"f() { git sw HEAD~1 \"$@\" && git reset \"$@\"; }; f"
# Discard all non-commited changes
discard = checkout --
# Reset back to the state before the last executed git command
undo = reset HEAD@{1}
# Ignore local content changes to tracked file
ignore-changes = update-index --assume-unchanged
# Allow the file to be tracked by git again; aka undo `ignore-changes`
track-changes = update-index --no-assume-unchanged
# View files marked with --assume-unchanged
ignored-files = !"git ls-files -v | grep '^[[:lower:]]'"
# Print the number of commits by each author
count-commits = shortlog -s -n
# Open the last 10 commits to be ReOrdered, deleted, squashed, etc.
ro = rebase -i HEAD~10
# Open the last N commits to be ReOrdered, deleted, squashed, etc.
ron = !"f() { git rebase -i HEAD~$1; }; f"
# View what commits have not been checked into master
cl-br = !"f() { git log master..\"$@\"; }; f"
# Note: Reset, rebase and merge all save your original HEAD pointer to ORIG_HEAD. Thus these commands have been run since the rebase you're trying to undo then you'll have to use the reflog.
undo-re = reset --hard ORIG_HEAD
#### Conflicts ####
# list all conflicted files
conf-ls = diff --name-only --diff-filter=U
# add the conflicted files after you fix them
conf-add = !"git conf-ls | xargs git add"
# Resolve conflict by discarding local changes
conf-ours = !"git conf-ls | xargs git checkout --ours"
#### Branches ####
# View all local branches
br = branch
# View all remote and local branches
br-remote = branch -a
# Checkout to another branch (SWitch)
sw = checkout
# Rename a branch
mvbr = branch -m
# Forces a deletion on the branch
rmbr = branch -D
# Delete a remote branch
rmbr-remote = push origin --delete
# Create new branch based off origin/master and checkout into the given name
cdbr = !"f() { git checkout -b \"$@\" remotes/origin/master; }; f"
# Print the name of the current branch
currbr = rev-parse --abbrev-ref HEAD
# Fetches origin and rebases for this branch
rbbr = !"git fetch origin && git rebase origin/$(git currbr) --stat"
# Fetches origin and rebases on top of this branch, ignoring local changes
rbbr-ours = !"git fetch origin && git rebase -Xours origin/$(git currbr) --stat"
# Fetches origin and rebases ontop on master
rbor = !"git fetch origin && git rebase origin/master --stat"
# Fetches origin and rebases ontop on master, ignoring local changes
rbor-ours = !"git fetch origin && git rebase -Xours origin/master --stat"
# Fetches upsteam and rebases ontop on master
rbor-upstream = !"git fetch upstream && git rebase upstream/master --stat"
# Fetches upsteam and rebases ontop on master
rbbr-upstream = !"git fetch upstream && git rebase upstream/$(git currbr) --stat"
# This will now checkout to the middle commit between now and the last known good commit. If the build succeeds, use `git bisect good`. If it fails, use ``git bisect bad`
bi = !"f() { git bisect start && git bisect bad && git bisect good \"$@\"; }; f"
# Resets the current branch to the latest branch while ignoring local changes
pull-ignore-local = !"git fetch origin && git reset --hard origin/$(git currbr)"
# View last 10 local branches sorted by last commit in descending order
brst = for-each-ref --sort=-committerdate --count=10 refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
# View all local branches sorted by last commit in ascending order
brsort = for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
# View all remote branches sorted by last commit in ascending order
remotebrsort = for-each-ref --sort=committerdate refs/remotes/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' | tail -10
# Tag the branch then delete it, effectively keeping the branch around without it cluttering your list
archive-br = !"f() { git tag archive/\"$@\" \"$@\" && git branch -D \"$@\"; }; f"
# Restore the archived branch
restore-br = !"f() { git checkout -b \"$@\" archive/\"$@\"; }; f"
#### Given File Change ####
# Shortcut and improvement for log on a file (beyond file renames)
lgf = !"f() { git log --follow \"$@\"; }; f"
# view commit log with changes of given file
logf = !"f() { git log --follow -p --full-history -- \"$@\"; }; f"
# view commit log with changes of given file in editor
logf-editor = !"f() { git log --follow -p \"$@\" > \"$@\".log && nvim \"$@\".log && rm \"$@\".log; }; f"
# view reflog log of given file
reflogf = rev-list --all
#### All File Changes ####
# Shortcut for `git diff`
df = diff
# Shortcut for `git difftool` with no prompt
dt = difftool -y
# View the changes made in the last commit - df = diff last
dl = diff HEAD^ HEAD
# View the changes made in the commit N from the current - Diff Last with Number
dln = !"f() { git diff HEAD~\"$1\" HEAD \"${@:2}\"; }; f"
# view the file changed list in the last commit - cl = see last
cl = diff-tree --no-commit-id --name-status -r HEAD^ HEAD
# view reflog with time info
reflog = reflog --date=iso
# view the file changed list in the given commit ID
cinfo = diff-tree --no-commit-id --name-status -r
# View a list of all deleted files
deleted = log --diff-filter=D --summary | grep delete
# List all existing files being tracked by the current branch
tracked = !"f() { git ls-tree -r $(git currbr) --name-only; }; f"
# view the file changes in the given commit ID
cdiff = !"f() { git diff \"$@\"^ \"$@\"; }; f"
# view all files given author has touched
touched = !"f() { git log --no-merges --stat --author=\"$@\" --name-only --pretty=format:"" | sort -u; }; f"
# View all the commits I have merged
commits = !"f() { git log --name-status --author="\"$@\""; }; f"
# Print the unstaged files
unstaged-files = !"f() { git diff --name-only; }; f"
# Print the staged files
staged-files = !"f() { git diff --staged --name-only --diff-filter=ACMRT; }; f"
# Untracks the given file
untrack = !"f() { git rm -r --cached \"$@\"; }; f"
# Adds the worktree with the given directory name off master. Run this in the main repo
add-wt = !"f() { git worktree prune && git worktree add ../\"$@\" master; }; f"
#### Disabled ####
# Git log graph
# lg= log --graph --all --decorate
# Delete your local branches that have been merged into master
# clear_merged_br () { git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d; }
# Check if the given branch has not been altered in over 4 weeks
# br-la = log -1 --after='4 weeks ago' -s