forked from whiteinge/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
189 lines (153 loc) · 6.93 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
[user]
email = [email protected]
name = Seth House
[push]
default = current
[alias]
b = branch -vv
bc = branch --contains
cdate = "!git --no-pager log -1 --format='%ci'"
ca = commit --amend --no-edit
cm = commit --amend -o
ci = commit
cp = commit --patch
co = checkout
d = diff
dc = diff --cached
dh = "!git diff --color | diff-highlight | less -r"
i = ghissues
m = merge --no-ff
mt = mergetool
p = push
rl = reflog --date=relative
short = rev-parse --short
sh = show --summary --stat --pretty=fuller --patch
st = status -s -b
stat = diff --stat
untracked = ls-files --others --exclude-standard
# Fetch all or one remote: git f; git f upstream
f = "!sh -c 'git fetch --tags ${1:-\"--all\"}' -"
# Interactive rebase against upstream HEAD or ref: git r; git r HEAD~10
r = "!sh -c 'git rebase -i ${1:-\"@{u}\"}' -"
# Rebase against upstream HEAD or ref: git r; git r HEAD~10
rup = "!sh -c 'git rebase ${1:-\"@{u}\"}' -"
# Reset HEAD and the index to upstream or ref: git re; git rs HEAD~1
rs = "!sh -c 'git reset --soft --keep ${1:-\"@{u}\"}' -"
# Hard reset to upstream or ref: git re; git rh HEAD~1
rh = "!sh -c 'git reset --hard ${1:-\"@{u}\"}' -"
# Fast-forward merge upstream or ref: git up; git up myremote/mybranch
up = "!sh -c 'git merge --ff-only ${1:-\"@{u}\"}' -"
# Make a stub commit with file and file contents. Useful for demoing.
stub = "!sh -c 'echo $1 > $1; git add $1; git commit -m Add-$1' -"
# Cherry-pick a commit directly into the working directory.
cherry-patch = "!sh -c 'git show \"$1\" | git apply' -"
# Perform a merge in-memory and output if any conflicts are found (dry-run)
# Takes the name of a branch / ref to merge
mergetest = "!sh -c 'git merge-tree `git merge-base $1 HEAD` $1 HEAD \
| awk '\\''/^@@/ { print \"Conflicts found\"; exit 1 }'\\''' -"
# Delete all remote refs that have been merged into the current branch.
# Usage: git deleteremote <remote-name>
deleteremote = "!sh -c 'git branch -r --merged \
| awk -F/ -v remote=${1:?Missing remote name.} \
'\\''$0 ~ remote && !/(master|develop)/ { print \"refs/heads/\" $2 }'\\'' \
| xargs -p -r git push ${1} --delete' -"
l = log --format=format:'%C(auto)%h%d%C(reset) %s %C(bold blue)(%an, %ar)%C(reset)'
ll = log --stat --decorate --abbrev-commit --date=relative
lll = log -p --stat --decorate --abbrev-commit --date=relative --color-moved
llll = "!sh -c 'git lll $@ \
| gvim - -R -v -c \"set ft=git\" -c \"set fdm=syntax\"' -"
lt = log --topo-order --format=format:'%C(auto)%h%d%C(reset) %s %C(bold blue)(%an, %ar)%C(reset)'
lm = log --oneline --decorate --topo-order --merges --ancestry-path
# Show the Git log and automatically shorten & search for a SHA. E.g.:
# git lf deb8dff8d8c1ed8acb7d7a2ec1158e7db136aab3
lf = "!sh -c 'GIT_PAGER=\"$PAGER -p $(git short $1)\" git l' -"
ltf = "!sh -c 'GIT_PAGER=\"$PAGER -p $(git short $1)\" git lt' -"
# http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html
ctags = !.git/hooks/ctags
# Open all modified files into Vim's quickfix.
# E.g.: git editm
editm = "!zsh -c '$EDITOR -q <(git diff -p -U0 --diff-filter=AM \
| diff-to-quickfix)'"
# Open all files changed within a commit range into Vim's quickfix.
# Defaults to HEAD.
# E.g.: git editc HEAD~3..
editc = "!zsh -c '$EDITOR -q <(git diff-tree -p -U0 --diff-filter=AM -r \
\"${1:-HEAD}\" \
| diff-to-quickfix)' -"
# Alias to make an archive with a prefix set to the name of the repo.
# git tar <ref> (defaults HEAD)
tar = "!bash -c 'REF=${1:-HEAD}; \
BASE=$(basename $(git rev-parse --show-toplevel)); \
git archive --prefix=${BASE}/ -o ${BASE}-$(git describe ${REF}).tar.gz ${REF}' -"
# Fetch all remotes in parallel using processes
fetchall = "!git remote | xargs -I@ -P10 git fetch @"
# Show the correct SHA for merging from FETCH_HEADS
showfetchhead = "!awk '!/not-for-merge/ {print $1}' \
$(git rev-parse --git-dir)/FETCH_HEAD"
# Compare local branches to remote branches (without doing a fetch!)
# Takes (optional) remote name as an argument; default: "upstream".
# FIXME: branches that are ahead of upstream will also be shown.
showstale = "!bash -c 'join -j 2 \
<(git show-ref --heads) \
<(git ls-remote --heads ${1:-upstream}) \
| awk '\\''{ if ($2 != $3) print $1 }'\\''' -"
# Find the merge-base of an old branch merge.
# This is useful for rebasing an old pull request onto a new branch.
# The output from this command is used as the <upstream> argument to
# ``git rebase --onto <newbase> <upstream> <branch>``
# where <branch> is the current branch.
#
# Specify the branch the pull request was originally merged into.
#
# Usage: git preqbase upstream/develop
#
preqbase = "!sh -c 'parent1=$(git rev-list --merges --parents $1 \
| awk -v head=\"$(git rev-parse HEAD)\" '\\''$3 == head { print $2 }'\\'');\
git merge-base \"$parent1\" HEAD' -"
# Show individual diffs for all incoming/outgoing changesets
in = pagediffs ..@{u}
out = pagediffs @{u}..
# Merge a GitHub pull request into the current branch.
# Usage: git preq <preq>
# Usage: git preq <preq> <remote>
preq = "!sh -c 'git pull --no-ff ${2:-upstream} refs/pull/${1:?Missing preq}/head' -"
# Same thing but for GitLab:
mreq = "!sh -c 'git pull --no-ff ${2:-upstream} refs/merge-requests/${1:?Missing preq}/head' -"
# Make a local branch from a remote branch somewhere on GitHub.
# Usage git ghbranch username reponame remotebranchname localbranchname
ghbranch = "!sh -c 'git fetch [email protected]:${1:?Missing user}/\
${2:?Missing repo}.git \
${3:?Missing remote branch}:${4:?Missing local branch}' -"
# Configure local clone to also make local refs for all GitHub pull
# requests for the specified remote
# Usage: git addrefspr upstream; git fetch upstream; git show upstream/pr/13
addrefspr = "!sh -c 'git config --add \
remote.${1:?Missing remote}.fetch \"+refs/pull/*/head:refs/remotes/$1/pr/*\"' -"
permission-reset = "!git diff -p -R --no-color \
| grep -E '^(diff|(old|new) mode)' --color=never \
| git apply"
[core]
excludesfile = ~/.gitignore
[color]
ui = auto
[init]
templatedir = ~/.git_template
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
smtpuser = [email protected]
smtpserverport = 587
[commit]
template = ~/.gitmessage
[pager]
# Don't paginate the oneline log output if less than one page.
l = $PAGER -F
lt = $PAGER -F
b = $PAGER -F
[merge]
tool = diffconflicts
[mergetool]
keepBackup = false
[mergetool "diffconflicts"]
cmd = vim -c DiffConflicts \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\"
trustExitCode = true