1
+ [core]
2
+ quotepath = false
3
+ autocrlf = input
4
+ [color]
5
+ ui = auto
6
+ [alias]
7
+ # @Requires the following scripts (all available in this repo):
8
+ # git-get-latest-jira-id
9
+ # get-getm
10
+ # git-sync-origin
11
+ # git-of-interest
12
+ # git-pull-request
13
+
14
+ ## Committing
15
+ ##--------
16
+
17
+ # Commit
18
+ ci = commit
19
+ # Commit w/ message
20
+ cim = commit -m
21
+ # Amend commit
22
+ cia = commit --amend
23
+ # Amend commit w/message
24
+ ciam = commit --amend -m
25
+ # Add changed files and then commit w/message
26
+ cam = commit -a -m
27
+ # Commit and add files
28
+ ca = commit -a
29
+ # These are the same as cam, ca and squish, except it adds new files as well
30
+ acam = !git add -A && git commit -m
31
+ aca = !git add -A && git commit
32
+ asquish = !git add -A && git commit --amend -C HEAD
33
+ # Adds all changed files into the last commit
34
+ squish = commit -a --amend -C HEAD
35
+ # Adds only staged files into the last commit
36
+ squeeze = commit --amend -C HEAD
37
+
38
+ # camm and cimm, acts as cam and cim aliases
39
+ # but automatically creates a message using the last JIRA ticket it can find (if any)
40
+ # can take one optional parameter which is the message to use after the
41
+ # ticket ID (by default, this is "Source formatting")
42
+ camm = "!f() { ticketId=$(git get-latest-jira-id $2); git commit -a -m \"$ticketId - ${1:-Source formatting}\"; }; f"
43
+ cimm = "!f() { ticketId=$(git get-latest-jira-id $2); git commit -m \"$ticketId - ${1:-Source formatting}\"; }; f"
44
+
45
+ ## Branches
46
+ ##--------
47
+
48
+ # Checkout
49
+ co = checkout
50
+ # Checkout last branch
51
+ col = checkout -
52
+ # Branch
53
+ br = branch
54
+ # create a branch by name, or if it exists, checkout the branch
55
+ cb = "!f() { git checkout -b $1 2> /dev/null && echo Created new branch $1 || `git checkout $1`; }; f"
56
+ # "Refreshes" the current branch (deletes the local and remote, and recreates it)
57
+ refresh = "!f() { git co $(git getm) && git db-all $1; git cb $1; }; f"
58
+ # Move all commits after the passed one to a new branch
59
+ # eg. git split 5c29ab4 custom-feature
60
+ split = "!f() { git checkout -b $2 && msg=$(git stash save) && git checkout - && git reset --hard $1 && git checkout $2 && [[ ! $msg =~ ^'No local changes to save'$ ]] && git stash pop; }; f"
61
+
62
+ ## Merging
63
+ ##--------
64
+
65
+ # Merge
66
+ mg = merge
67
+ # Merge abort
68
+ mga = merge --abort
69
+ # Merge master into current branch
70
+ mm = !git merge $(git getm)
71
+
72
+ ## Rebasing
73
+ ##--------
74
+
75
+ # Rebase
76
+ rb = rebase
77
+ # Abort rebase
78
+ rba = rebase --abort
79
+ # Continue rebase
80
+ rbc = rebase --continue
81
+ # Skip patch
82
+ rbs = rebase --skip
83
+ # Rebase interactively
84
+ rbi = rebase -i
85
+ # Rebase on top of master
86
+ rbm = !git rebase $(git getm)
87
+ # Rebase on top of master interactively
88
+ rbim = rebase -i $(git getm)
89
+
90
+ ## Resetting
91
+ ##--------
92
+
93
+ # Reset
94
+ rs = reset
95
+ # Reset hard
96
+ rsh = reset --hard
97
+ # Reset soft
98
+ rss = reset --soft
99
+
100
+ ## Deleting
101
+ ##--------
102
+
103
+ # Delete a local branch
104
+ db = branch -D
105
+ # Delete a remote branch
106
+ db-remote = !sh -c 'git push origin :$0'
107
+ # Delete both the local and remote branches
108
+ db-all = !sh -c 'git db $0 && git db-remote $0'
109
+
110
+ # Delete the current local branch and checkout master
111
+ dbc = "!f() { local bn=$1; [[ -z $bn ]] && bn=$(git brn); master=$(git getm); [[ $bn == $master ]] && echo Cannot remove "$master" && exit; git co $master && git db $bn; }; f"
112
+
113
+ ## Pushing
114
+ ##--------
115
+
116
+ # Syncs from upstream, then pushes the master branch to origin and upstream
117
+ push-allm = "!master=$(git getm); git sync-origin $master && git push origin $master && git push upstream $master;"
118
+ # Syncs from upstream, then pushes the master branch to origin and upstream
119
+ push-all = "!f() { current_branch=$(git brn); git sync-origin $current_branch && git push origin $current_branch && git push upstream $current_branch; }; f"
120
+
121
+ pa = !git push-all
122
+ pam = !git push-allm
123
+ pum = push upstream $(git getm)
124
+ pbo = !git push origin $(git brn)
125
+
126
+ pu = pull upstream
127
+ fu = fetch upstream
128
+
129
+ ## Syncing
130
+ ##--------
131
+
132
+ # Sync master from upstream to origin
133
+ # This alias will stash current changes, switch to master, sync, then switch back to the original branch and apply the stash
134
+ som = "!f() { local current_branch=$(git brn); local saved_index=0; local stash_save_result=`git stash save`; [[ $stash_save_result == *\"HEAD is now at\"* ]] && saved_index=1; master=$(git getm); git checkout $master && git sync-origin $master && git checkout $current_branch && ([[ $saved_index == 1 ]]) && git stash pop; }; f;"
135
+ # Sync current branch with changes from upstream/master to the current branch on origin
136
+ so = !git sync-origin $(git getm)
137
+ # Sync current branch from upstream to origin
138
+ sbo = !git sync-origin $(git brn)
139
+ # Update current branch from origin
140
+ ubo = !git pull origin $(git brn)
141
+
142
+ ## Logging
143
+ ##--------
144
+
145
+ # Pretty graph
146
+ lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative
147
+ lgd = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(cyan)<%an>%Creset' --abbrev-commit --date=default
148
+ # lg graph with the names of the files that have changed
149
+ lgst = !git lg --stat $@
150
+ # lg graph with the changes between the current branch and master
151
+ lgm = !git lg $(git getm)..
152
+ # lg graph with grepping on the log
153
+ lgg = "!f() { git lg --grep=\"$1\"; }; f"
154
+ # lg graph with searching the changes
155
+ lgs = "!f() { git lg -S\"$1\"; }; f"
156
+ # lg graph of just the latest commit
157
+ hd = !git --no-pager log --pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative -1
158
+ head = !git log -n1
159
+ tip = !git log --format=format:%h | head -1
160
+ tipl = !git log --format=format:%H | head -1
161
+
162
+ ## Stashing
163
+ ##--------
164
+
165
+ # Apply stash (newest by default)
166
+ sa = "!f() { local stash_rev=stash@{${1:-0}}; git stash apply $stash_rev; }; f"
167
+ # Pop stash (newest by default)
168
+ sp = "!f() { local stash_rev=stash@{${1:-0}}; git stash pop $stash_rev; }; f"
169
+ # Save stash (includes untracked files)
170
+ ss = !git add . && git stash save
171
+ # List all entries in the stash
172
+ sl = stash list
173
+
174
+ ## Diffing
175
+ ##--------
176
+
177
+ dt = difftool
178
+ dtc = difftool --cached
179
+
180
+ # List the filenames and diff stats for a commit/treeish
181
+ dl = "!f() { ref_spec=$(git get-custom-refspec $1); git diff --stat $ref_spec; }; f"
182
+ # Show the patch for a commit/treeish
183
+ delta = "!f() { ref_spec=$(git get-custom-refspec $1); git diff $ref_spec; }; f"
184
+ # Show *just* the file names that have been changed for a commit/treeish
185
+ ldl = "!f() { local ref_spec=$(git get-custom-refspec $1); git diff --pretty='format:' --name-only $ref_spec; }; f"
186
+
187
+ ## Opening files
188
+ ##--------
189
+
190
+ # open batch of files
191
+ bopen = "!f() { local ref_spec=$(git get-custom-refspec $1); editor=`git config --get user.editor`;files=`git diff --pretty=format: --name-only $ref_spec`;useopen=`command -v open`; usecygwin=`command -v cygstart`; [[ -n $useopen ]] && open -a \"$editor\" $files && exit $?; [[ -n $usecygwin ]] && editor=$(cygpath -d $editor); for i in $files; do echo opening $i; $usecygwin $editor $i; done }; f"
192
+ # open each file individually
193
+ open = "!f() { local ref_spec=$(git get-custom-refspec $1); editor=`git config --get user.editor`;files=`git diff --pretty=format: --name-only $ref_spec`;useopen=`command -v open`; usecygwin=`command -v cygstart`; [[ -n $useopen ]] && for i in $files; do echo opening $i; $useopen -a \"$editor\" $i; done && exit $?; [[ -n $usecygwin ]] && editor=$(cygpath -d $editor); for i in $files; do echo opening $i; $usecygwin $editor $i; done }; f"
194
+ # Open all files that are different from master
195
+ openm = !git open $(git getm)..
196
+
197
+ ## Submodules
198
+ ##--------
199
+
200
+ # Update submodules
201
+ subu = submodule update
202
+ # Update submodules and initialize them
203
+ subi = submodule update --init
204
+
205
+ ## Submitting Pull Requests
206
+ ##--------
207
+
208
+ # Pull request
209
+ pr = pull-request
210
+ # Show pull requests w/stats
211
+ prs = pull-request stat
212
+ # Submit pull request and close the current one
213
+ prcs = !git pr submit -q && git pr close
214
+ # Sets the update branch based on the current repo directory name (so liferay-portal-ee-6.1.x will have an update branch of ee-6.1.x)
215
+ set-pr-branch-config = "!f(){ git config "git-pull-request.$(git rev-parse --show-toplevel).$1" "$2"; }; f"
216
+ set-update-branch = "!f(){ git set-pr-branch-config "update-branch" "${1:-$(git getm)}"; }; f"
217
+ set-work-dir = "!f(){ git set-pr-branch-config "work-dir" "$1"; }; f"
218
+
219
+ ## Misc
220
+ ##--------
221
+
222
+ # Checkout master
223
+ m = !git co $(git getm)
224
+
225
+ # Shortcut for help
226
+ h = help
227
+
228
+ # Cherry-pick
229
+ cp = cherry-pick
230
+
231
+ # Get the current branch name
232
+ brn = "!git branch $* | grep '^*' | sed 's/^* //'"
233
+
234
+ # Get the last mentioned JIRA ticket id from the commit log
235
+ get-latest-jira-id = "!f() { git log $1 --oneline | grep -Eo '([A-Z]{3,}-)([0-9]+)' -m 1; }; f"
236
+
237
+ # Open the url to the latest JIRA ticket referenced in the log
238
+ jira = "!f() { ticketId=$(git get-latest-jira-id $2); open http://issues.liferay.com/browse/$ticketId; }; f"
239
+
240
+ # Get a range based commit-ish based on the passed sha. Uses HEAD by default, but if a sha is passed, it creates a range
241
+ # that refers to one previous. If you pass a range, it will leave it untouched so that you can customize the range yourself.
242
+ # Used in many aliases
243
+ # eg. git get-custom-refspec # prints HEAD^..HEAD
244
+ # git get-custom-refspec ^ # prints HEAD^..
245
+ # git get-custom-refspec 81c35e1 # prints 81c35e1^..81c35e1
246
+ # git get-custom-refspec 5250022..master # prints 5250022..master
247
+ get-custom-refspec = "!f() { to_rev=${1:-HEAD}; [[ $to_rev == ^ ]] && to_rev=HEAD^..; old_head=${to_rev}^; new_head=$to_rev; if [[ $to_rev == *..* ]]; then old_head=${to_rev%%..*}; new_head=${to_rev#*..*}; fi; ref_spec=$old_head..$new_head; echo $ref_spec; }; f"
248
+
249
+ # Rank contributors by number of commits
250
+ stats = shortlog -s -n
251
+
252
+ # Same as add, but uses the verbose option since git add doesn't inform you of what exactly you just added
253
+ aa = add -v
254
+
255
+ # List ignored files
256
+ ls-ignored = ls-files --exclude-standard --ignored --others
257
+
258
+ # Reset last commit
259
+ pop = reset HEAD^
260
+
261
+ # Remove untracked files and directories
262
+ cln = clean -f -d
0 commit comments