-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitconfig
executable file
·156 lines (128 loc) · 5.41 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
[core]
excludesfile = /Users/Thomas/.gitignore_global
autocrlf = input
preloadindex = true
filemode = false
ignorecase = false
commentChar = ";"
[push]
default = upstream
[pull]
rebase = merges
[rebase]
autostash = true
[fetch]
prune = true
fetch = +refs/heads/*:refs/remotes/origin/*
[rerere]
enabled = false
autoupdate = true
[difftool]
prompt = false
[user]
name = Thomas Heartman
email = [email protected]
[filter "lfs"]
clean = git-lfs clean %f
smudge = git-lfs smudge %f
required = true
[alias]
# common shortcuts
co = checkout
s = switch
ci = commit
br = branch -a
sh = stash
cp = cherry-pick
# less common shortcuts
st = status -sb
ren = branch -m
p = pull --ff-only
# rebase
pfwl = push --force-with-lease
preb = pull --rebase
rc = rebase --continue
ri = rebase --interactive
amend = commit --amend --no-edit
rerereoff = !git config rerere.enabled false
rerereon = !git config rerere.enabled true
rererest = !git config --get rerere.enabled
rmrerere = !git config --remove-section rerere
# cleaning
brclean = "!f() { git branch --merged origin/main | grep -v main | xargs -r git branch -d; }; f"
# recent history
standup = !sh -c \"git log --pretty=format:'%C(auto)%h %B' --decorate --date=short --since=yesterday --author='$(git config --get user.email)'\"
# log
le = log --oneline --decorate
lg = log --color --graph --pretty=format:'%Cred%h%Creset%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%C(magenta)\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%C(magenta)\\ [%cn]" --decorate --numstat
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%C(magenta)\\ [%cn]" --decorate --date=short
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%C(magenta)\\ [%cn]" --decorate --date=relative
# who has worked on this repo within the last year?
reviewers = "shortlog --summary --numbered --email --after='1 year ago'"
# list modified files in last commit
dl = "!git ll -1"
# diff last commit
dlc = diff --cached HEAD^
dr = "!f() { git diff -w "$1"^.."$1"; }; f"
diffr = "!f() { git diff "$1"^.."$1"; }; f"
# merge/diff
mergetest = "!f(){ git fetch; git merge --no-commit --no-ff \"${1-origin/main}\" | grep CONFLICT; if [ $? == 0 ]; then echo -e \"\\033[1;31m --- Merge will conflict :( --- \\033[0m\"; else echo -e \"\\033[1;32m --- No conflict in merge :) --- \\033[0m\"; fi; git merge --abort; }; f " # "Dry-run" merge towards origin/main by default. Can pass another branch as 1st param.
conflicts = diff --name-only --diff-filter=U
dt = difftool
mt = mergetool
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
type = cat-file -t
dump = cat-file -p
# reset commands
r = reset
r1 = reset HEAD^
r2 = reset HEAD^^
rh = "!f() { git reset --hard ${1-\"@{u}\"}; }; f" # rh main -> reset hard to main. rh -> reset hard to upstream branch
rh1 = reset HEAD^ --hard
rh2 = reset HEAD^^ --hard
# list aliases
la = "!git config -l | grep alias | cut -c 7-"
# stash
sl = stash list
sa = stash apply
ss = stash save
# config
whoami = !git config --get user.name
iam = !git config user.name
amnesia = !git config --unset user.name
# misc
ignored = ls-files --others --i --exclude-standard
todo = grep -i -n -e TODO -e FIXME -e NOTE
# TH shortcuts
#utility
fs = "!f(){ git fetch --prune; git st;}; f"
pushup = "push -u origin HEAD" #push branch to origin
del = "!f(){ git push origin --delete "$1"; git branch -D "$1"; }; f"
rekt = "!f() { git reset --hard ${1-\"@{0}\"}; }; f" # CHANGE: revert to the last commit rather than to upstream
#housekeeping
#merges and then deletes the merged branch. HANDLE WITH CARE
mdel ="!f(){ git merge \"$1\"; git del \"$1\"; }; f"
#optimising workflow. Use this instead of pull
# params
# $1: the branch to update to
# $2: the remote to update from (optional, defaults to origin)
# update "!f() { git fetch "${2-origin}" --prune; git merge --ff-only "${2-origin}"/$1 || git rebase --preserve-merges "${2-origin}"/$1; }; f"
update = "!f() { git fetch "@{u}" --prune; git merge --ff-only "@{u}" || git rebase --preserve-merges "@{u}"; }; f"
tidy = "!f() { if [ $# -eq 0 ]; then REBASE_TARGET="@{u}"; elif [ ${#1} -ge 4 ]; then REBASE_TARGET=$1; else REBASE_TARGET="head~$1"; fi; git rebase -i $REBASE_TARGET; }; f"
rename = git branch -m
diffc = "diff --cached"
[status]
submoduleSummary = true
[credential]
helper = cache --timeout=144000
[includeIf "gitdir:~/projects/work/"]
path = ~/.gitconfig.work
[merge]
conflictStyle = diff3
autostash = true
[github]
user = thomasheartman
[init]
defaultBranch = main