forked from weikinhuang/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitconfig
More file actions
200 lines (185 loc) · 6.25 KB
/
.gitconfig
File metadata and controls
200 lines (185 loc) · 6.25 KB
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
[user]
# name = $GIT_AUTHOR_NAME
name =
# email = $GIT_AUTHOR_EMAIL
email =
[github]
# To get the token: git hub-token
# apitoken = $GIT_HUB_API_TOKEN
apitoken =
[color]
ui = auto
[advice]
pushNonFastForward = false
statusHints = false
[core]
whitespace = fix,trailing-space,space-before-tab,indent-with-non-tab
autocrlf = input
filemode = false
pager = less -x1,4 -iFXRS
# editor = $EDITOR
[apply]
whitespace = nowarn
[branch]
autosetupmerge = true
[push]
default = tracking
[rerere]
enabled = true
[diff]
renames = copies
mnemonicprefix = true
tool = auto-difftool
[merge]
stat = true
tool = auto-mergetool
[difftool]
prompt = false
[mergetool]
prompt = false
[difftool "auto-difftool"]
cmd = git-auto-difftool $LOCAL $REMOTE
[mergetool "auto-mergetool"]
cmd = git-auto-mergetool $BASE $LOCAL $REMOTE $MERGED
[help]
autocorrect = 1
[branch "master"]
merge = refs/heads/master
remote = origin
[alias]
### Basic shortcuts
git = !git
cl = clone --recursive
st = status
br = branch
co = checkout
df = diff
lg = log -p
cp = cherry-pick
ss = stash
sp = stash pop
sl = stash list
sa = stash apply
si = stash --keep-index
### Verbose output about tags, branches or remotes
tags = tag -l
branches = branch -a
remotes = remote -v
### Adding
au = add -u .
rml = rm --cached
### Committing
# Commit
ci = commit
# Commit w/ message
cim = commit -m
# Amend commit
cia = commit --amend
# Amend commit w/message
ciam = commit --amend -m
# Add changed files and then commit w/message
cam = commit -a -m
# Commit and add files
ca = commit -a
# These are the same as cam, ca and squish, except it adds new files as well
acam = !git add -A && git commit -m
aca = !git add -A && git commit
asquish = !git add -A && git commit --amend -C HEAD
# Adds all changed files into the last commit
squish = commit -a --amend -C HEAD
# Adds only staged files into the last commit
squeeze = commit --amend -C HEAD
# Amends last commit using the same commit message
amend = !"git log -n 1 --pretty=tformat:%s | git commit -F - --amend"
### Checkout / Branching
# go to master branch
com = checkout master
# Checkout last branch
col = checkout -
# Switch to a branch and reset it, creating it if necessary
go = checkout -B
# create a branch by name, or if it exists, checkout the branch
cb = "!f() { git checkout -b "$1" 2> /dev/null && echo Created new branch \\'$1\\' || git checkout "$1"; }; f"
# Get the current branch name
brn = "!git branch "$@" | grep '^*' | sed 's/^* //' && true"
# Update current branch from origin
ubo = !"git pull origin $(git brn) && true"
# Get the merge base for this branch
branch-root = !"git merge-base $(git brn) master && true"
brt = !"git branch-root"
### Rebase
rb = rebase
# Abort rebase
rba = rebase --abort
# Continue rebase
rbc = rebase --continue
# Skip patch
rbs = rebase --skip
# Rebase interactively
rbi = rebase -i
# rebase with master branch
rbm = rebase master
# rebase with master branch
rbim = rebase -i master
### Resetting
# resets the file to clean copy
undo = checkout --
# remove files from index (tracking)
unstage = reset HEAD
# go back before last commit, with files in uncommitted state
uncommit = reset --soft HEAD^
### Logging
# View the SHA, description, and history graph of the latest commits
l = log --pretty=oneline --graph --decorate --all
# show tree view of the git log
tree = log --graph --decorate --pretty=oneline --abbrev-commit --all
# searching the history
search = log -p -S
rsearch = log -p -G
### Diffing
# Open the difftool for all files that are currently modified
diffall = !"git diff --name-only "$@" | while read filename; do git difftool "$@" --no-prompt "$filename" & done && true"
### Pushing
# Undo a `git push`
undopush = push -f origin HEAD^:master
### Submodules
# Update submodules
subu = submodule update
# Update submodules and initialize them
subi = submodule update --init
### Syncing
# Go to master and pull in origin master
pm = !"git checkout master && git pull origin master && true"
# Pull in remote changes for the current repository and all its submodules
p = !"git pull; git submodule foreach git pull origin master && true"
# Pull in remote changes for the current repository and update all submodules
ps = !"git pull; git submodule foreach git submodule update --init --recursive && true"
# Push the current branch to origin with the same branch name
pob = !"git push "$@" origin $(git brn) && true"
### Misc
# Merge and squash commits from remote branches
pulley = !"git checkout master && git checkout -b "$3" && git pull "$1" "$2" && git checkout master && git merge --no-commit --squash "$3" && git commit -a && git branch -D "$3""
# searches for all detached commits
lost = !"git fsck | awk '/dangling commit/ {print $3}' | git show --format='SHA1: %C(yellow)%h%Creset %f' --stdin | awk '/SHA1/ {sub(\"SHA1: \", \"\"); print}' && true"
# Adds a file to be ignored
ignore = !"echo "$1" >> .gitignore && true"
### Editing
# Editing and adding conflicted files: when we get many merge conflicts
# and want to quickly solve them using an editor, then add the files.
# Customize this by replacing "emacs" with your preferred editor.
edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; $EDITOR "$(f)""
add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add "$(f)""
########### GITHUB based aliases
# Go to the master branch then sync local and origin with [upstream|origin]
sync = !"git checkout master && git pull $(R="$(git remote -v | grep '^upstream\\>')"; if [ $? -eq 0 ]; then echo 'upstream'; else echo 'origin'; fi) master && git submodule update && git push origin master && true"
# Pushes current branch to origin and then issues a pull request to upstream
pr = hub-pull-request
# Gets the github url for current repo
hub = !"echo "https://github.com/"$(git config remote.origin.url) | sed -E s/[a-z]+@github\\.com:// | sed s/\\.git$// && true"
# Gets the url to github of the current commit
hub-url = !"sh -c 'HEAD=$(git rev-parse HEAD) && SHA1=$([ "$0" = "sh" ] && echo $HEAD || echo $0) && echo $(git hub)"/commit/"${SHA1}' && true"
# custom diff chunk headers
[diff "js"]
xfuncname = "^[ \\t]*((((.+) *: *function *\\()|(function .+ *\\()).+)$"
[diff "css"]
xfuncname = "^[ \\t]*(.+ *{ *)$"