forked from whiteinge/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
155 lines (125 loc) · 5.42 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
[user]
email = [email protected]
name = Seth House
[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
rl = reflog --date=relative
short = rev-parse --short
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}\"}' -"
# 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
llll = "!sh -c 'git lll $@ \
| gvim - -R -v -c \"set ft=git\" -c \"set fdm=syntax\"' -"
lt = log --oneline --decorate --topo-order
lm = log --oneline --decorate --topo-order --merges --ancestry-path
# http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html
ctags = !.git/hooks/ctags
# Open all modified files in EDITOR
editm = "!$EDITOR $(git ls-files -m)"
# 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' -"
### Custom Git commands (found in ~/bin)
# Push only the current branch to the upstream branch
p = pushcurrent
# 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>
preq = "!sh -c 'git pull upstream refs/pull/${1:?Missing preq}/head' -"
# 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/*\"' -"
[core]
excludesfile = ~/.gitignore
[color]
ui = auto
[init]
templatedir = ~/.git_template
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
smtpuser = [email protected]
smtpserverport = 587
[diff]
tool = clivimdiff
[difftool "clivimdiff"]
cmd = gvimdiff -v $LOCAL $REMOTE
[merge]
tool = diffconflicts
[mergetool "diffconflicts"]
cmd = diffconflicts $EDITOR $BASE $LOCAL $REMOTE $MERGED
trustExitCode = true
keepBackup = false
[mergetool "gdiffconflicts"]
cmd = diffconflicts gvim $BASE $LOCAL $REMOTE $MERGED
trustExitCode = true
keepBackup = false