-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathslides_git_rebasing.html
More file actions
140 lines (124 loc) · 6.49 KB
/
slides_git_rebasing.html
File metadata and controls
140 lines (124 loc) · 6.49 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Slides for
Git Rebasing — Ruby on Rails Guides
</title>
<link rel="stylesheet" type="text/css" href="stylesheets/style.css" data-turbo-track="reload">
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print">
<link rel="stylesheet" type="text/css" href="stylesheets/highlight.css" data-turbo-track="reload">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="stylesheets/reset.css">
<link rel="stylesheet" href="stylesheets/reveal.css">
<link rel="stylesheet" href="stylesheets/myslide.css" id="theme">
<link rel="stylesheet" href="stylesheets/code.css">
<script src="javascripts/clipboard.js" data-turbo-track="reload"></script>
<script src="javascripts/slides.js" data-turbo-track="reload"></script>
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>Git Rebasing</h1><p>This Guide will elaborate on teamwork in git
and using branches.</p><p>After reading this guide, you will know:</p>
<ul>
<li>How to rebase your branch</li>
</ul>
<p><small>Slides - use arrow keys to navigate, esc to return to page view, f for fullscreen</small></p>
</section>
<section><a class='slide_break' href='git_rebasing.html#slide-0'>▻</a>
<h2 id="how-git-works"><a class="anchorlink" href="#how-git-works"><span>1</span> How git works</a></h2></section>
<section><a class='slide_break' href='git_rebasing.html#slide-1'>▻</a>
<h3 id="what-is-a-commit-what-is-a-branch"><a class="anchorlink" href="#what-is-a-commit-what-is-a-branch"><span>1.1</span> What is a commit, what is a branch.</a></h3><p>Every commit is just a small change that
points to the commit before.</p><p>A branch is just a pointer to a certain commit.</p><p>If you create a branch called <code>a3</code> and add
a few commits W, X, Y, and Z to it, it might look like this:</p><p><img src="images/git_branch.svg" alt=""></p><p>If you merge back into main now everything will be fine.</p><p>But what if the main branch moves on?</p></section>
<section><a class='slide_break' href='git_rebasing.html#slide-2'>▻</a>
<h3 id="merging-two-branches"><a class="anchorlink" href="#merging-two-branches"><span>1.2</span> Merging two branches</a></h3><p>Let's say three other commits are added to the main: B, C and D:</p><p><img src="images/git_branches.svg" alt=""></p></section>
<section><a class='slide_break' href='git_rebasing.html#slide-3'>▻</a>
<p>If you merge this, the merge might get complicated.
A new Commit is created that contains all the necessary changes:</p><p><img src="images/git_merge.svg" alt=""></p></section>
<section><a class='slide_break' href='git_rebasing.html#slide-4'>▻</a>
<h3 id="rebasing-a-branch"><a class="anchorlink" href="#rebasing-a-branch"><span>1.3</span> Rebasing a branch</a></h3><p>But there's a better approach: First you rebase your branch onto the main:</p><div class="interstitial code">
<pre><code class="highlight plaintext">git checkout a3
git rebase main
</code></pre>
<button class="clipboard-button" data-clipboard-text="git checkout a3
git rebase main
">Copy</button>
</div>
<p>This will try to apply the new commits in a4 on top
of the current state of main, leading to this situation:</p><p><img src="images/git_rebase.svg" alt=""></p><p>After the rebase a merge into main will be simple.</p></section>
<section><a class='slide_break' href='git_rebasing.html#slide-5'>▻</a>
<h3 id="rebase-your-feature-branch"><a class="anchorlink" href="#rebase-your-feature-branch"><span>1.4</span> Rebase your feature branch</a></h3><p>When working with feature branches you try to merge as fast as possible.
But if the main branch moves on while you are working on your feature,
you can use <code>git rebase</code> to catch up:</p><div class="interstitial code">
<pre><code class="highlight shell"><span class="nb">git </span>fetch
<span class="nb">git </span>checkout a3
<span class="nb">git </span>pull origin a3
<span class="nb">git </span>rebase main
<span class="c"># fix problems, run test, fix problems again</span>
<span class="nb">git </span>push <span class="nt">-f</span> origin a3 <span class="c"># overwrite branch with rebased branch</span>
<span class="c"># work on your merge request</span>
</code></pre>
<button class="clipboard-button" data-clipboard-text="git fetch
git checkout a3
git pull origin a3
git rebase main
# fix problems, run test, fix problems again
git push -f origin a3 # overwrite branch with rebased branch
# work on your merge request
">Copy</button>
</div>
</section>
<section><a class='slide_break' href='git_rebasing.html#slide-6'>▻</a>
<h3 id="resources"><a class="anchorlink" href="#resources"><span>1.5</span> Resources</a></h3>
<ul>
<li><a href="https://git-scm.com/book/en/v2/Git-Branching-Rebasing">Git Book: Chapter 3.6</a></li>
</ul>
</div></section>
</div>
</div>
<!-- End slides. -->
<!-- Required JS files. -->
<script src="javascripts/reveal.js"></script>
<script src="javascripts/search.js"></script>
<script src="javascripts/markdown.js"></script>
<script>
// Also available as an ES module, see:
// https://revealjs.com/initialization/
Reveal.initialize({
controls: false,
progress: true,
center: false,
hash: true,
// The "normal" size of the presentation, aspect ratio will
// be preserved when the presentation is scaled to fit different
// resolutions. Can be specified using percentage units.
width: 1000,
height: 600,
disableLayout: false,
// Factor of the display size that should remain empty around
// the content
margin: 0.05,
// Bounds for smallest/largest possible scale to apply to content
minScale: 0.2,
maxScale: 10.0,
keyboard: {
27: () => {
// do something custom when ESC is pressed
var new_url = window.location.pathname.replace('slides_', '') + window.location.hash.replace('/','slide-');
window.location = new_url;
},
191: 'toggleHelp',
13: 'next', // go to the next slide when the ENTER key is pressed
},
// Learn about plugins: https://revealjs.com/plugins/
plugins: [ RevealSearch, RevealMarkdown ]
});
</script>
</body>
</html>