-
Notifications
You must be signed in to change notification settings - Fork 1
/
extra-slides.html
153 lines (138 loc) · 4.99 KB
/
extra-slides.html
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
<!DOCTYPE html>
<html>
<head>
<title>Git Panic and how to avoid it: Extra slides</title>
<meta charset="utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
<meta name="description" content="A presentation about advanced git topics and using git the right way" />
<link rel="stylesheet" href="build/bundle.css" />
</head>
<body>
<div id="presentation" class="reveal">
<div class="slides">
<section id="title">
<h1>Git Panic</h1>
<h2>and how to avoid it</h2>
<h3>/ super hidden extra slides /</h3>
</section>
<section id="remote-names">
<h3>Attack of the clones</h3>
<div>If you have multiple remotes, use "clone -o"<br /> to set a more meaningful remote name than "origin"</div>
<pre><code class="bash">
# Use -o to give a meaningful name to the remote
git clone REMOTE_URL -o "remote_name"
</code></pre>
</section>
<section id="normal-vs-bare">
<h3>Normal vs bare init</h3>
<pre><code class="bash">
# bare repos don't have a working tree
# which is useful for a shared remote
git init vs git init --bare
</code></pre>
<img src="images/normal-vs-bare.png" />
</section>
<section id="checkout-m">
<h3>That's for another branch</h3>
<div>Use "-m" if you have changes to your work tree<br/>
that you need to move to a different branch</div>
<pre><code class="bash">
# by default checkout refuses to switch branches
# if your work directory is dirty
# "-m" does a three-way merge between the current branch
# your working tree contents, and the new branch
git checkout -m <commitish>
</code></pre>
</section>
<section id="stash">
<h3>The stash is like a branch</h3>
<div>The dog ate my stash, maaan</div>
<pre><code class="bash">
# save unfinished work as a new commit
git stash save -p "unfinished work"
# stash list and reflog stash are the same
git stash list
git reflog stash
# stash show and show stash are the same
git stash show -p
git show stash@{0}
# pop vs apply
git stash pop stash@{1}
git stash apply stash@{1}
</code></pre>
</section>
<section id="tag-and-squash">
<h3>Tag and squash</h3>
<pre><code class="bash">
# tag the feature branch
git tag "feature_branch_done"
# squash using either reset or rebase
git reset --soft HEAD~5
git commit -m "squashed_feature"
</code></pre>
</section>
<section id="hooks">
<h3>Git hooks</h3>
<img width="50%" src="images/git-hooks.jpg" />
</section>
<section id="pre-commit-hook">
<h3>Example pre-commit hook</h3>
<pre><code class="bash">
# .git/hooks/pre-commit
# hook must be executable
#!/bin/sh
# run linter and tests
# if either commands exit status is non zero
# the commit process will be canceled
npm run lint
npm run test
</code></pre>
</section>
<section id="message-template-hook">
<h3>Example commit message template hook</h3>
<pre><code class="bash">
# .git/hooks/prepare-commit-msg
# hook must be executable
#!/bin/sh
# puts the name of the current branch
# in the commit message template
echo "[`git rev-parse --abbrev-ref HEAD`] \
MESSAGE HERE" > "$1"
</code></pre>
</section>
<section id="deployment-hook">
<h3>Example simple deployment hook</h3>
<pre><code class="bash">
# .git/hooks/post-receive
# hook must be executable
GIT_WORK_TREE=/app_code git checkout master -f
cd /app_code
npm install
npm run build
npm run restart
echo "deployed"
</code></pre>
</section>
<section id="the-end">
<h3>No more slides, go away</h3>
<img width="45%" src="images/dev-by-0.jpg" />
</section>
</div>
<script src="build/bundle.js"></script>
<script>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-93032616-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>