-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitconfig
132 lines (104 loc) · 4.27 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
[user]
name = Ta Dat
email = [email protected]
[color]
diff = auto
branch = auto
status = auto
[alias]
# Amend
ca = commit --amend
c = commit
p = pull
co = checkout
cp = cherry-pick
l = log
# Show list of changed files with each commits
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lp = log -p
w = commit -am 'wip'
st = status
dc = diff --cached
d = diff
b = branch
sl = stash list
sa = stash apply
ss = stash save
bl = blame
# List commits with pretty commit message and author
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
# Show git log tree
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
# Show commits with relative dates
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
# Show all changes related to a file
filelog = log -u
# Find file
f = "!git ls-files | grep -i"
# Grep for a string in codebase
grep = grep -Ii
# Show all git alias
la = "!git config -l | grep alias | cut -c 7-"
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
bn = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
pb = "!git push -u origin $(git branch-name)"
# Delete the remote version of the current branch
unpublish = "!git push origin :$(git branch-name)"
upb = "!git push origin :$(git branch-name)"
# Delete a branch and recreate it from master — useful if you have, say,
# a development branch and a master branch and they could conceivably go
# out of sync
recreate = "!f() { [[ -n $@ ]] && git checkout \"$@\" && git unpublish && git checkout master && git branch -D \"$@\" && git checkout -b \"$@\" && git publish; }; f"
# Fire up your difftool (e.g. Kaleidescope) with all the changes that
# are on the current branch.
code-review = difftool origin/master...
# Given a merge commit, find the span of commits that exist(ed) on that
# branch. Again, not so useful in itself, but used by other aliases.
merge-span = "!f() { echo $(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f1)$1$(git log -1 $2 --merges --pretty=format:%P | cut -d' ' -f2); }; f"
# Find the commits that were introduced by a merge
merge-log = "!git log `git merge-span .. $1`"
# Show the changes that were introduced by a merge
merge-diff = "!git diff `git merge-span ... $1`"
# As above, but in your difftool
merge-difftool = "!git difftool `git merge-span ... $1`"
# Interactively rebase all the commits on the current branch
rebase-branch = "!git rebase -i `git merge-base master HEAD`"
# merge master develop
merge-master-develop = "!git checkout master; git pull; git checkout develop; git pull; git checkout -b merge/master_develop_$(date +'%Y%m%d'); git merge master --no-ff"
#
# Working with files
#
# Unstage any files that have been added to the staging area
unstage = reset HEAD
# Show changes that have been staged
diffc = diff --cached
# Mark a file as "assume unchanged", which means that Git will treat it
# as though there are no changes to it even if there are. Useful for
# temporary changes to tracked files
assume = update-index --assume-unchanged
# Reverse the above
unassume = update-index --no-assume-unchanged
# Show the files that are currently assume-unchanged
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
# Checkout our version of a file and add it
ours = "!f() { git checkout --ours $@ && git add $@; }; f"
# Checkout their version of a file and add it
theirs = "!f() { git checkout --theirs $@ && git add $@; }; f"
# List modified files
mod-files = "diff --name-only --diff-filter=U"
# Trace all changes to a specific files
trace = "log --pretty=short --abbrev-commit -p -M --follow --stat"
# Update all branches
update = pull --rebase --autostash
[core]
editor = /usr/bin/vim
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true