This repository has been archived by the owner on May 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitconfig
235 lines (175 loc) · 6.78 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
[user]
name = John Doe
email = [email protected]
[color]
ui = true
[diff]
# Uncomment the line below after setting up an external diff tool via https://gist.github.com/bkeating/329690
# external = /Users/mike/bin/git-diff-cmd.sh
[push]
# Uncomment the line below if using Git 1.8+
# default = simple
[rebase]
autosquash = true
[alias]
# Remote Sync
# --------------------------------------------------------------------------
# Sync files with the remote host (see 'User configuration' in .profile)
# Disabled by default; uncomment the line below to use
# usage: git fs
# fs = !"fs && true" # Filesync ON
fs = !"true" # Filesync OFF
# Branching
# --------------------------------------------------------------------------
b = branch
co = checkout
# Check out the local master branch
# usage: git com
com = checkout master
# Create and check out a new branch
# usage: git new BRANCH_NAME
# example: git new bugfix
new = checkout -b
# Rename a branch
# usage: git rename [OLD_BRANCH_NAME] NEW_BRANCH_NAME
# example: git rename bugfixes
rename = branch -m
# Create a local copy of a remote branch
# usage: git copy REMOTE_USER REMOTE_BRANCH
# example: git copy mpetrovich bugfix
copy = !"git fetch $1 $2 && git checkout -b $2 $1/$2 && true"
# Delete a single branch locally and in the origin (be careful!)
# usage: git delete BRANCH_NAME
# example: git delete bugfix
delete = !"git branch -D "$1"; git push origin :$1 && true"
# Show all remotes
# usage: git remotes
remotes = remote -v show
# History
# --------------------------------------------------------------------------
# Search the git log using a grep pattern
# usage: git lg "REGEX"
# example: git lg "debug\b"
lg = log --grep
# Show all commits made since local master
# usage: git l
l = !"git --no-pager log master..HEAD --abbrev-commit --pretty=oneline"
# Show a visualization of the commit history
# usage: git tree
tree = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
# ...with timestamps
# usage: git tree2
tree2 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(bold cyan)%aD%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
# Reviewing
# --------------------------------------------------------------------------
# Show files with uncommitted changes
# usage: git st
st = status
# ...abbreviated
# usage: git s
s = status -sb
# Show all uncommitted changes inline, not using an external diff viewer
di = diff --no-ext-diff
# Show unstaged changes made in the current branch
# usage: git du
du = diff
# Show diff inline, not using an external diff viewer
dui = diff --no-ext-diff
# Show staged changes made in the current branch
# usage: git ds
ds = diff --staged
# Show diff inline, not using an external diff viewer
dsi = diff --staged --no-ext-diff
# Show all changes made since master
# usage: git dm
dm = diff master
# Show diff inline, not using an external diff viewer
dmi = diff master --no-ext-diff
# Interactively stage changes
# usage: git istage
istage = add -p
# Unstage all staged commits
# usage: git unstage
unstage = reset HEAD --
# Remove any uncommitted changes, including new & removed files
# CAUTION: This is destructive and cannot be undone
# usage: git nuke
nuke = !"git reset --hard && git clean -fd"
# Stashing
# --------------------------------------------------------------------------
sl = stash list
sa = stash apply
sp = stash pop
sd = stash drop
# Stash all uncommitted changes, including new & removed files
# usage: git ss "STASH_LABEL"
# example: git ss "Work in progress"
ss = stash save --include-untracked
# Stash only unstaged changes
# usage: git su
su = stash save --keep-index
# Committing
# --------------------------------------------------------------------------
# Commit only staged changes with the given commit message
# usage: git cm "MESSAGE"
# example: git cm "Fix bug for XYZ"
cm = commit -m
# Commit all changes with the given commit message
# usage: git cma "MESSAGE"
# example: git cma "Fix bug for XYZ"
cma = !"git add --all && git commit -a -m"
# Amend the last commit with only staged changes
# usage: git amend
amend = !"git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend"
# Amend the last commit with all changes
# usage: git amend
amenda = !"git add --all && git amend"
# Amend the last commit with any staged changes and a different message
# usage: git amendm "MESSAGE"
# example: git amendm "Fix bugs for XYZ"
amendm = commit --amend -m
# Commit all changes as a work-in-progress commit
# usage: git wip
wip = !"git add --all && git commit -a -m "WIP" --no-verify"
# Undo a work-in-progress commit (ie, opposite of `git wip`)
# usage: git unwip
unwip = !"git undo && git unstage"
# Squash all commits made since master
# usage: git squash "MESSAGE"
# example: git squash "Fix bug for XYZ"
squash = !"COMMITS=`git rev-list --count HEAD ^master`; git reset --soft HEAD~$COMMITS; git commit -m \"$1\" && true"
# Un-commit the last commit, but keep it staged
# usage: git undo [NUMBER_OF_COMMITS=1]
# example: git undo # Last commit
# example: git undo 3 # Last 3 commits
undo = !"git reset --soft HEAD~$1 && true"
# Updating
# --------------------------------------------------------------------------
# Rebase the current branch against master
# usage: git rb
rb = !"git rebase master && git fs"
# ...interactively
# usage: git rbi
rbi = !"git rebase master --interactive && git fs"
# Commits all resolved conflicts and continues the rebase
# usage: git rbc
rbc = !"git add --all && git rebase --continue"
rbs = rebase --skip
rba = rebase --abort
# Update master with the latest from upstream,
# and rebase the current branch against it
# usage: git latest
latest = !"git checkout master && git pull upstream master && git push origin HEAD && git checkout - && git rebase master && git fs"
# Pushing
# --------------------------------------------------------------------------
p = push origin HEAD
pf = push origin HEAD --force
# Miscellaneous
# --------------------------------------------------------------------------
# Find a file by name
# usage: git find FILENAME
# example: git find index.php
find = !"sh -c 'git ls-tree -r --name-only HEAD | grep --color $1' -"
# Lists all aliases in this file
# usage: git aliases
aliases = !"cat ~/.gitconfig"