-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgitconfig
282 lines (217 loc) · 9.61 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
[user]
email = [email protected]
name = devpew
signingkey = FDEEAE6DA1E8ED84
[core]
editor = vim
excludesfile = ~/.gitignore_global
[color]
ui = auto
[color "branch"]
current = green bold
local = white
remote = white dim
[color "diff"]
meta = magenta bold
frag = yellow bold
old = red bold
new = green bold
whitespace = red reverse
[color "status"]
added = green bold
changed = red bold
untracked = yellow bold
[push]
default = simple
[alias]
# ------------------------------------------------------------
# Status and view files
# ------------------------------------------------------------
# Default status with all of the untracked files
s = status --untracked-files=all
# Short status with all of the untracked files
ss = status --short --branch --untracked-files=all
# See the short history of a file: $ git fl README.md
fl = "!git ls --follow"
# See the diff history of a file: $ git fll README.md
fll = log -u
# Verbose version of `remote` to show URLs: $ git remotes
remotes = remote -v
# Get the branch name (used in aliases): $ git current-branch-name
current-branch-name = "!git rev-parse --abbrev-ref HEAD"
# Get the current branch remote name (if any)
current-remote-name = "!git rev-parse --abbrev-ref --symbolic-full-name @{u}"
# List local branches verbose: $ git br
b = branch --verbose
# List local + remote branches verbose: $ git bra
ba = branch --verbose --all
# Show all of the ignored files
ign = ls-files -o -i --exclude-standard
# Show tags sorted by creation date
tags = "!git for-each-ref --sort=taggerdate --format '%(tag)%09%(taggerdate:raw)%09%(*authorname)%09%(*subject)' refs/tags | awk '{print $1\"\t\t\"strftime(\"%F %H:%M\", $2)\"\t\"$4\" \"$5\" \t\t\"$6\" \"$7\" \"$8\" \"$9\" \"$10}'"
# ------------------------------------------------------------
# Logs (You may append -4 to see last 4 only to each statement)
# ------------------------------------------------------------
# Short commit history: $ git ls
ls = log --pretty=format:"%C(bold\\ yellow)%h%C(bold\\ green)\\ (%ad)%Cred%d\\ %Creset%s%C(cyan)\\ %Creset[%C(bold\\ blue)%cn%Creset]" --decorate --graph --date=relative --abbrev
# Commit history showing changed files: $ git ll
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%C(cyan)\\ (%ad)%Creset[%C(blue)%cn%Creset]" --decorate --graph --numstat --date=relative
# Same as `ls` but dates are absolute: $ git lsd
lsd = log --pretty=format:"%C(yellow)%h%C(cyan)\\ (%ad)%Cred%d\\ %Creset%s%C(cyan)\\ %Creset[%C(blue)%cn%Creset]" --decorate --graph
# Same as `ll` but dates are absolute: $ git lld
lld = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%C(cyan)\\ (%ad)%Creset[%C(blue)%cn%Creset]" --decorate --graph --numstat
# ------------------------------------------------------------
# Diffs
# ------------------------------------------------------------
# Shortcut for diff: $ git d
d = diff
# Same as `diff` but just names: $ git diff-names
diff-names = diff --stat
# Same as `diff` but for staged (cached) files: $ git diff-cached
diff-cached = diff --cached
# Same as `diffc` but just names: $ git diff-names-cached
diff-names-cached = diff --cached --stat
# Diff with origin/master
diff-master = diff origin/master
# Diff with origin master but only names
diff-master-names = diff origin/master --stat
# Show the diff between the current commit and the last X ones: $ git difflast || $ git difflast 2
difflast = "!f() { git diff HEAD~${1-1}; }; f"
diffl = "!git difflast"
dl = "!git difflast"
# Same as `difflast` but just names: $ git difflastn || $ git difflastn 2
difflastn = "!f() { git diffs HEAD~${1-1}; }; f"
diffln = "!git difflastn"
dln = "!git difflastn"
# ------------------------------------------------------------
# Checkout
# ------------------------------------------------------------
# Checkout shortcut
co = checkout
# Create a new branch and checkout to it: $ git cob new_branch
cob = checkout -b
# Checkout to the master branch
com = checkout master
# Same as `cob` but first update the current branch: $ git new feature
# Depends on alias:update
new = "!f() { git update; git cob ${1}; }; f"
# ------------------------------------------------------------
# Adding files and commiting
# ------------------------------------------------------------
# Add all modification and deletions of already versioned files: $ git a
a = "!git add -u && git ss"
# Same as `a` but include new files also: $ git aa
aa = "!git add -A && git ss"
# Commit shortcut with message: $ git cm "Commit message"
cm = commit -m
# Add versioned changes and commit: # git cma "Commit message"
cma = "!git a && git cm"
# Add versioned changes + new files and commit: # git cmaa "Commit message"
cmaa = "!git aa && git cm"
# Work in progress. Add everything and do a temporal commit. Then you
# can do `unwip` to keep working: $ git wip
wip = "!git cmaa 'Work In Progress - Savepoint'"
# Reset the previous commit as if it was never commited but keep working files
# as they are: $ git unwip
unwip = reset HEAD~1 --mixed
# Fix the last commit message (this will change the commit id): $ git cmfix
cmfix = commit --amend
# ------------------------------------------------------------
# Fetching
# ------------------------------------------------------------
# Fetch origin
fo = fetch origin
# Fetch the current branch changes from the origin: $ git fb
fc = "!git fetch origin $(git current-branch-name)"
# Same as `f` but end with a git status: $ git fo
fcs = "!git fc && git ss"
# ------------------------------------------------------------
# Pulling
# ------------------------------------------------------------
# Pull the current branch changes from the origin: $ git pl
pl = "!git pull origin $(git current-branch-name)"
# ------------------------------------------------------------
# Pushing
# ------------------------------------------------------------
# Push the current branch changes to the origin: $ git ps
ps = "!git push origin $(git current-branch-name)"
# ------------------------------------------------------------
# GIT FLOW - HELPERS
# ------------------------------------------------------------
# Update current branch with rebase
#
# 1. Stashes all local commits
# 2. Pulls from origin/<branch> to update tree
# 3. Puts all stashed local commits on top
#
# If there are any merge conflicts then for each conflict file do:
# a. Correct the conflicts
# b. git add . <file_name>
#
# Then do `$ git rebase --continue`
#
update = "!git pull --rebase --prune origin $(git current-branch-name)"
# Checkout to another branch
# Update that branch
# Return to your current branch
#
# $ git co-up master
#
update-branch = "!f() { CBRANCH=$(git current-branch-name) && git co ${1} && git update && git co $CBRANCH; }; f"
# Update your branch and the push your changes. This will only
# affect your current branch
publish = "!git update && git ps"
# 1. Update the parent branch
# 2. Rebase your branch with the parent branch
#
# $ git sync <parent_branch> // (master or your parent branch)
#
# NOTE: It will fail if your branch is tracking a remote branch
#
# What it does
# 1. It will checkout to <parent_branch> and do update (to fetch for recent changes)
# 2. It will return to <branch> and rebase <parent_branch> (put parent commits before branch commits)
#
sync = "!f() { git sync-check-no-remote-present && CBRANCH=$(git current-branch-name) && git co ${1} && git update && git co $CBRANCH && git rebase ${1}; }; f"
# Return the amount of lines that do not contain a 'fatal' error.
# If the branch has a remote it will return 1.
# If the branch has no remotes then it will return 0.
sync-current-has-remote = "!git current-remote-name | grep -v fatal: | wc -l"
# Exit as failure if the branch has a remote
sync-check-no-remote-present = "!f() { exit $(git sync-current-has-remote); }; f"
#
# Proper reset
#
# There will be times when you explore a promising idea in code and it turns out to be
# crap. You just want to throw your hands up in disgust and burn all the work in your
# working directory to the ground and start over.
#
# In an attempt to be helpful, people might recommend: git reset HEAD --hard.
#
# Slap those people in the face. It’s a bad idea. Don’t do it!
#
# That’s basically a delete of your current changes without any undo. As soon as you run
# that command, Murphy’s Law dictates you’ll suddenly remember there was that one gem among
# the refuse you don’t want to rewrite.
#
# Too bad. If you reset work that you never committed it is gone for good. Hence, the wipe alias.
#
# This commits everything in my working directory and then does a hard reset to remove that commit.
# The nice thing is, the commit is still there, but it’s just unreachable. Unreachable commits are a
# bit inconvenient to restore, but at least they are still there. You can run the git reflog command
# and find the SHA of the commit if you realize later that you made a mistake with the reset. The
# commit message will be “WIPE SAVEPOINT” in this case
#
# Usage: $ git wipe
#
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
clippy = !sh -c 'git $1 | cowsay -n -f ~/.config/cows/clippit.cow' -
clippit = !sh -c 'git $1 | cowsay -n -f ~/.config/cows/clippit.cow' -
[credential]
helper = cache
[init]
templatedir = .git-templates
[commit]
gpgsign = true
[gpg]
program = gpg2