forked from r4bds/r4bds.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlecture_lab07.qmd
292 lines (153 loc) · 9.6 KB
/
lecture_lab07.qmd
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
---
title: "Lecture Lab 7"
author: "Nils Hofmann"
format:
revealjs:
embed-resources: true
theme: moon
slide-number: c/t
width: 1600
height: 900
mainfont: avenir
logo: images/r4bds_logo_small.png
footer: "R for Bio Data Science"
---
## Which questions you can answer after today's lecture?
- What does version control mean?
- How does Git and GitHub relate to this and what is their difference?
- Why do Git and teamwork go hand in hand in data science?
- How to use Git in a team
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# Talk about assignment issues and why git could help them---------------------------------------------------------------------- -->
## Git/GitHub - Why you should care
- Teamwork and Git belong together in Data Science/Computer Science
- GitHub and reproducible data science go hand in hand
- There will be the moment when git will safe a lot of time in a big project
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# Think more about motivation and about need to know---------------------------------------------------------------------- -->
## Things that happen without version control
![](images/memes_lab07.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Version Control - What and why
Think about your own a experiences with coding and how a system could remove these issues. Also what should this system have if you work with others on one project
Collect your ideas at the course [Padlet](https://padlet.com/s2206721/what-could-version-control-mean-yj6uerzlld8eu3rg)
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Version Control - Definition
- Version control is like a special "undo" button for your work.
- remembers all the changes you make, so you can always go back to an older version
- Lets you and your friends work on the same project without mixing up each other's changes.
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Git - An open source version control system
- installed locally on your device
- keeps track of your file changes
- each change is indexed, so you can revert your current state
- You interact with it via the terminal and control your **local repository**
![](images/Git_logo.jpg){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## GitHub
- Hub = Server where you can find, store and manage repositories
- everything is remote
- a platform which provides a GUI for your repository and enables users to share code easily
- you interact with it via an application or a web browser and control your **remote repository**
![](images/github_logo.jpg){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Git and GitHub together
- GitHub allows you to have the project repository remotely
- Multiple people who have git installed can then access this repository and create a copy
- GitHub introduces visual features and eases the project management
![](images/git_github_basic_workflow.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Git - The basics
staging area = like a container with the changes for the next commit
![](images/git_workflow.jpeg){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Git - simple workflow when working together
![](images/workflow_git_simple.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## If you forget to pull...
- if you and your teammate work on the same codeline and both push the results to the remote repository, git will detect a merge conflict
- conflict = two changes in the same line of the same file
! git will not know the version you prefer
![](images/no_pulling_conflict.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Git in RStudio
![](images/git_gui_rstudio.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Git in RStudio - Commit in GUI
- commit message = very short summary of new changes to your project
![](images/git_gui_commiting.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## GitHub - Overview
- you can browse through all open source software
![](images/github_basic_overview.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## GitHub - Use the README!
- README.md is like a quarto document
- you can combine code and text to design a short "manual" for your users
![](images/readme_github.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Git - working together with clone or fork
- you can create a copy of the current state of the project by cloning or forking
- cloning: work in same remote repository
- forking: create and work in your own remote repository
![](images/fork%20and%20clone(2).png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Git - When should I use clone and fork now?
- it is a question of:
- How much control do I want?
- How do I want to continue with the project as a collaborator?
- fork = you will have complete control over the repository
- **BUT** your collaborators will not be able to apply and use your changes
- If you **plan to contribute** to a target repository you typically **clone it**
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# Mention the something about use cases of branches in software development ---------------------------------------------------------------------- -->
## Git - Branches
- branch: new **separate** and **isolated** version of the mother branch
- useful for: experimenting, bug fixing, adding features
- see it as a structural component for **organizing a project**
![](images/git_branch_example.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Git - Merge
- helps to combine changes from two branches into a single branch
- **current branch**: The branch to be merged
- **target branch**: The branch in which we want to merge the current branch
- Why F in merged target branch?
= new index for a new commit
![](images/git_merge.png){fig-align="center"}
<!--# ---------------------------------------------------------------------- -->
<!--# SLIDE ---------------------------------------------------------------- -->
<!--# ---------------------------------------------------------------------- -->
## Questions? ...