-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitconfig
168 lines (110 loc) · 4.47 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
[user]
name = cosimo.scarcella
email = [email protected]
[core]
# Auto-converting CRLF line endings into LF. For Operating System compatibility
# 'true' if you use Windows OS
# 'input' if you use Linux or MacOS
autocrlf = true
[alias]
### BASIC SHORTCUTS ###
cl = clone
ci = commit
pl = pull
co = checkout
br = branch
cp = cherry-pick
r = reset
# Show status concisely
st = status -s
# Fetch branches and tags removing any remote-tracking references that no longer exist on the remote
f = fetch -apt
# Incorporates changes from a remote repository into the current branch.
# Remove any remote-tracking references that no longer exist on the remote
pl = pull --prune
# Create and checkout a new branch
cob = checkout -b
# Checkout to previous branch
cop = checkout -
# Add changes from all tracked and untracked files
ad = add -A
# Commit with a message
cm = commit -m
# Amend the previous commit
amend = commit --amend
ca = commit --amend
# Amend the previous commit and leave the previous message unaltered
can = commit --amend --no-edit
# Push commits from the local git repository to the origin or upstream remotes
ps = !git push origin HEAD
# Push commits from the local git repository to the origin or upstream remotes and rewrite history
psf = !git push -f origin HEAD
# Initial empty commit
empty = "!git commit -am\"[empty] Initial commit\" --allow-empty"
# Blame a file
bl = blame
# Clean working directory
cc = clean -dfx
# Shelve files
shelve = stash --include-untracked
# Unshelve files
unshelve = stash pop
### DIFFERENCES BETWEEN FILES ###
# Shows the changes between the working directory and the index
diff = diff --word-diff
# Shows the changes between the index and the HEAD
dc = diff --cached
# Shows the changes between the index and the last commit
dlc = diff --cached HEAD^
# Shows changes from a revision ignoring whitespace when comparing lines
dr = "!f() { git diff -w "$1"^.."$1"; }; f"
# Shows changes from a revision
diffr = "!f() { git diff "$1"^.."$1"; }; f"
### FINDING FILES AND CONTENT INSIDE FILES ###
# Find a file path in codebase
ff = "!git ls-files | grep -i"
# Find a pattern with ignore-case avoiding binary files
grep = grep -Ii
gr = grep -Ii
### SHOW METADATA ###
# Shows .gitconfig file
ec = config --global -e
# List all your Aliases
la = "!git config -l | grep alias | cut -c 7-"
### RESET COMMANDS ###
# Going back to the commit before HEAD. Leave changes in the staging area
r1 = reset HEAD^
# Going back two commit before HEAD. Leave changes in the staging area
r2 = reset HEAD^^
# Hard reset shortcut
rh = reset --hard
# Going back to the commit before HEAD.
rh1 = reset HEAD^ --hard
# Going back two commit before HEAD.
rh2 = reset HEAD^^ --hard
### BRANCH OPERATIONS ###
# Delete local branch
del = branch -D
# Delete remote branch
delr = push origin --delete
# List all local branches and sort them by commit date, showing the most recent git branch first, based on commits made to it
brls = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
# List all remote branches and sort them by commit date, showing the most recent git branch first, based on commits made to it
brlsr = branch -r --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
### SHOW THE HISTORY OF COMMITS AND BRANCHES ###
# List commits in short form, with colors and branch/tag annotations.
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
# List commits showing changed files
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
# List oneline commits showing relative dates
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
# A short git log
le = log --oneline --decorate
# Shows the branches graph with date and contributor
lag = log --all --graph --pretty=format:'%C(yellow)%h%Creset -%C(bold blue)%d%Creset %s %Cgreen(%cr) %Cred<%an>%Creset'
# Shows the branch graph
tree = !git log --graph --decorate --all --oneline
### SHOW THE HISTORY OF A FILE, WITH DIFFS ###
# Show all the commits related to a file, with the diff of the changes
filelog = log -u
fl = log -u