-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
249 lines (242 loc) · 6.63 KB
/
index.html
File metadata and controls
249 lines (242 loc) · 6.63 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
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>reveal.js</title>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/monokai.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>Git Best Practices</h1>
</section>
<section>
<section>
<h2>Commit Related Changes</h2>
</section>
<section>
<p>A commit should be a wrapper for related changes.</p>
</section>
<section>
<pre>$ git add -p</pre>
</section>
<section>
<p>-p, --patch Use the interactive patch selection interface to chose which changes to commit.
</p>
</section>
</section>
<section>
<section>
<h2>Commit Often</h2>
</section>
<section>
<p>keeps your commits small and, again, helps you commit only related changes.</p>
</section>
</section>
<section>
<section>
<h2>Rebase Often</h2>
</section>
<section>
<p>keep your local working branch updated.</p>
</section>
</section>
<section>
<section>
<h2>Don’t Commit Half-Done Work</h2>
</section>
<section>
<p>You should only commit code when it’s completed.</p>
<p>If super big feature - split the feature’s implementation into logical chunks and remember to commit early and often.</p>
</section>
</section>
<section>
<section>
<h2>Test Before You Commit</h2>
</section>
<section>
<p>Test your code thoroughly to make sure it really is completed and has no side effects.</p>
</section>
</section>
<section>
<section>
<h2>Write Good Commit Messages</h2>
</section>
<section>
<p>Use the imperative, present tense ("change", not "changed" or "changes") to be consistent with generated messages from commands like git merge.</p>
</section>
</section>
<section>
<section>
<h2>Use Branches</h2>
</section>
<section>
<p>Neither use master nor develop when developing.</p>
<p>Always create new branch when starting new feature.</p>
<pre>$ git branch RT-1234 origin/master</pre>
<pre>$ git branch feature/RT-1234 origin/master</pre>
<pre>$ git checkout -b feature/RT-1234 origin/master</pre>
</section>
</section>
<section>
<section>
<h2>Be Explicit</h2>
</section>
<section>
<pre>$ git push</pre>
</section>
<section>
<pre>$ git push</pre>
<p>vs.</p>
<pre>$ git push origin my-local-branch</pre>
</section>
<section>
<pre>$ git push --force</pre>
</section>
<section>
<pre>$ git push --force</pre>
<p>vs.</p>
<pre>$ git push origin my-local-branch --force</pre>
</section>
<section>
<pre>--force</pre>
<p>vs.</p>
<pre>--force-with-lease</pre>
</section>
<section>
<pre>$ git push origin my-local-branch --force-with-lease</pre>
</section>
</section>
<section>
<section>
<h1>Merging vs. Rebasing</h1>
</section>
<section>
<pre>$ git pull</pre>
<h5>vs.</h5>
<pre>$ git rebase</pre>
</section>
<section>
<img data-src="/images/01.svg">
</section>
<section>
<pre>$ git fetch origin master</pre>
<pre>$ git merge origin/master</pre>
</section>
<section>
<img data-src="/images/02.svg">
</section>
<section>
<pre>$ git fetch origin master</pre>
<pre>$ git rebase origin/master</pre>
</section>
<section>
<img data-src="/images/03.svg">
</section>
<section>
<pre>$ git pull origin master --rebase</pre>
</section>
</section>
<section>
<section>
<h1>Rewriting History</h1>
</section>
<section>
<pre>$ git commit --amend</pre>
</section>
<section>
<pre>$ git rebase -i HEAD~4</pre>
</section>
<section>
<pre>
pick 07c5abd add login page
pick de9b1eb patch login page
pick 3e7ee36 some typosssss
pick fa20af3 fix something
# Rebase 8db7e8b..fa20af3 onto 8db7e8b
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
</pre>
</section>
</section>
<section>
<section>
<h1>Other Useful Commands</h1>
</section>
<section>
<pre>$ git cherry-pick commit-hash</pre>
</section>
<section>
<pre>$ git reset</pre>
<pre>$ git reset --hard HEAD~1</pre>
<pre>$ git reset --soft HEAD~1</pre>
<pre>$ git reset --mixed HEAD~1</pre>
</section>
<section>
<pre>$ git diff</pre>
<pre>$ git diff --staged</pre>
</section>
<section>
<pre>$ git stash</pre>
<pre>$ git stash save "name"</pre>
<hr>
<pre>$ git stash list</pre>
<hr>
<pre>$ git stash pop</pre>
<pre>$ git stash pop stash@{2}</pre>
<pre>$ git stash apply</pre>
</section>
<section>
<pre>$ git reflog</pre>
<pre>$ git reset HEAD@{2}</pre>
</section>
</section>
<section>
<h1>Thanks!</h1>
</section>
</div>
</div>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true }
]
});
</script>
</body>
</html>