forked from whiteinge/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
187 lines (154 loc) · 6.02 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
# Prefix commands with GIT_TRACE=1 to debug performance.
[user]
email = [email protected]
name = Seth House
[push]
default = current
[alias]
b = branch -vv --sort=-committerdate
ca = commit --amend --no-edit
cm = commit --amend -o
ci = commit
co = checkout
d = diff --summary --stat --patch
ds = d --cached
f = fetch --tags --all
ff = merge --ff-only
m = merge --no-ff
mt = mergetool
p = push
pushnoci = push -o ci.skip
r = rebase --autosquash
rh = reset --hard
short = rev-parse --short
ref = rev-parse --symbolic-full-name
sh = show --summary --stat --pretty=fuller --patch
st = status -s -b
sti = status -s -b --ignored
stat = diff --stat
sl = stash list --name-status --pretty='format:%gd [%ar]: %s'
uncommit = reset HEAD~1
lasttag = describe --abbrev=0
editc = quickfix
editm = quickfix -m modified
edits = quickfix -m staged
pg = pagediffs
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 --color-moved --pretty=fuller
lt = l --topo-order
lm = log --oneline --decorate --topo-order --merges --ancestry-path
rl = reflog --date=relative
rll = reflog --date=relative --stat
rlll = reflog --date=relative -p --stat --color-moved
# Show the Git log and automatically shorten & search for a SHA:
# git lf deb8dff8d8c1ed8acb7d7a2ec1158e7db136aab3
lf = "!_() { GIT_PAGER=\"$PAGER -p $(git short $1)\" git l; };_"
ltf = "!_() { GIT_PAGER=\"$PAGER -p $(git short $1)\" git lt; };_"
# Output alias definitions. Usage: git which st
which = "!_() { git config --global --get alias.$1; };_"
# Show which files have been changed the most.
churn = !git log --all -M -C --name-only --format='format:' "$@" \
| grep . | sort | uniq -c | sort -n -r
# Show the author information that will be used when writing commits.
whoami = !git var GIT_COMMITTER_IDENT | sed 's/>.*/>/'
# Output all the changes since the most recent tag as a Markdown list:
# git changelog
# git changelog HEAD~5...
changelog = "!_() { \
range=${1:-$(git lasttag)...HEAD}; \
printf 'Changes since %s\n\n' $range; \
git --no-pager log --reverse --no-merges --oneline \
--pretty=format:'- %h %s' \
$range; \
printf '\n'; \
};_"
# Make a stub commit with file and file contents. Useful for demoing.
stub = "!_() { echo $1 > $1; git add $1; git commit -m Add-$1; };_"
# Cherry-pick a commit into the working directory as unstaged changes.
cherry-patch = "!_() { git show \"${1:?Missing revision}\" | git apply; };_"
# Use a fuzzy-finder to find a SHA to use for a fixup commit.
fixup = !git l @{u}.. | fzy | awk '{ print $1 }' | xargs -I{} git ci --fixup={}
# Perform a merge in-memory and output if conflicts are found (dry-run):
# git mergetest otherbranch
mergetest = "!_() { \
git merge-tree \
$(git merge-base ${1:?Missing branch} HEAD) \
${1:?Missing branch} \
HEAD \
| awk '/<<<<<<</ { exit 1 }'; \
}; _"
# Fuzzy-find any Git ranges in the tmux scrollback then re-output as an
# in-progress git log command.
# Usage: git fetch && git frefs
frefs = "!scrollback | match-git-range | uniq | fzy | tr -d \\\\n \
| xargs -I{} tmux send git Space l Space {} Space"
# http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html
ctags = !.git/hooks/ctags
# Alias to make an archive with a prefix set to the name of the repo.
# git tar <ref> (defaults HEAD)
tar = "!zsh -c 'REF=${1:-HEAD}; \
BASE=$(basename $(git rev-parse --show-toplevel)); \
git archive --prefix=${BASE}/ -o ${BASE}-$(git describe ${REF}).tar.gz ${REF}' -"
# Merge a GitHub pull request into the current branch.
# Usage: git preq <preq>
# Usage: git preq <preq> [<remote>]
preq = "!_() { git pull --no-ff ${2:-upstream} refs/pull/${1:?Missing preq}/head; };_"
# Same thing but for GitLab:
mreq = "!_() { git pull --no-ff ${2:-origin} 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 = "!_() { \
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 = "!_() { git config --add remote.${1:?Missing remote}.fetch \
\"+refs/pull/*/head:refs/remotes/${1}/pr/*\" \
};_"
[commit]
verbose = 2
[core]
excludesfile = ~/.gitignore
[color]
ui = auto
[init]
# Use full path to dotfiles instead of the path to the symlinks in my
# homedir. This causes the target template files to get copied into new
# repos rather than copying the symlinks to those template files.
templatedir = ~/src/dotfiles/.git_template
[pager]
# Don't paginate the oneline log output if less than one page.
l = $PAGER -F
lt = $PAGER -F
b = $PAGER -F
branch = $PAGER -F
sl = $PAGER -F
stat = $PAGER -F
rl = $PAGER -F
[merge]
tool = diffconflicts
[mergetool]
keepBackup = false
[mergetool "vimdiff1"]
hideResolved = true
[mergetool "diffconflicts"]
cmd = vim -c DiffConflicts \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\"
trustExitCode = true
hideResolved = false
[diff]
tool = vimdiff
colorMoved = true
# If Git::LoadCPAN is not packaged for your distro:
# export PERL5LIB=/path/to/git/clone/perl
# [sendemail]
# smtpencryption = tls
# smtpserver = server
# smtpuser = user
# smtpserverport = port
[include]
path = ~/.gitemailconfig
path = ~/.gitconfig-customize