-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathslides.Rmd
289 lines (179 loc) · 5.42 KB
/
slides.Rmd
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
---
subtitle: "Go to next slide"
output: ioslides_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## GitHub flow + RStudio
_Mauro Lepore_
--
Repo: <http://bit.ly/github-demo>
Slides: <http://bit.ly/github-berlin>
--
### Set up issues?
* Use https://rstudio.cloud, or
* just watch and ask at the end.
# License
Creative Commons Attribution-ShareAlike 4.0 International
http://creativecommons.org/licenses/by-sa/4.0
--
Many images and ideas come from
https://jennybc.github.io/wtf-2019-rsc/
## Outline, part 1/2
Intro
* [Why Git/GitHub?](https://peerj.com/preprints/3159/)
* [Why Git**Hub** flow -- not Git flow?](https://githubflow.github.io/)
* Should I use a Git client?
Hands on
* GitHub flow from GitHub:
* [Contributor issues](https://github.com/maurolepore/github-demo/issues?q=is%3Aopen+is%3Aissue+label%3Acontributor+sort%3Acreated-asc+label%3Aberlin+label%3Agithub-flow_via-github).
* [Maintainer issues](https://github.com/maurolepore/github-demo/issues?q=is%3Aopen+is%3Aissue+sort%3Acreated-asc+label%3Aberlin+label%3Agithub-flow_via-github+label%3Amaintainer).
Recap
[Understanding the GitHub flow](https://guides.github.com/introduction/flow/).
## Outline, part 2/2
Hands on
* [GitHub flow via RStudio](https://github.com/maurolepore/github-demo/issues?q=is%3Aopen+is%3Aissue+label%3Aberlin+label%3Agithub-flow_via-rstudio+label%3Acontributor):
* Walk through [Fork and clone](https://happygitwithr.com/fork-and-clone.html).
* Search "Pull changes from upstream" [here](https://happygitwithr.com/upstream-changes.html). Notice:
```bash
git add remote upstream https://github.com/OWNER/REPO.git
git fetch upstream
git pull upstream master --ff-only
```
## Questions / Discussion
Ideas:
* [Git clients](https://github.com/2DegreesInvesting/resources/issues/5).
* usethis package: [Pull request helpers](https://usethis.r-lib.org/articles/articles/pr-functions.html).
# Appendix
## What is a commit?
<img src="https://i.imgur.com/fmrhQOQ.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/zizuprp.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/5MiM5RC.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/m230nzj.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/ZKksnVi.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/PAgI3mX.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/1nOkjOu.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/AoxcNpK.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/Gcv7fZU.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/HS2tUli.png" align="center" width=760/>
## What is a commit?
<img src="https://i.imgur.com/OPuzdBA.png" align="center" width=760/>
## Git configuration
In R
```R
usethis::edit_git_config()
```
In the terminal, e.g.:
```bash
git config --global -l
git config --global user.email "[email protected]"
git config --global user.name "maurolepore"
core.editor=notepad
push.default=current
pull.ff=only
```
[Cache credentials](https://happygitwithr.com/credential-caching.html#credential-caching)
## RStudio & terminal
<img src="https://i.imgur.com/spQyR4r.png" align="center" width=760/>
```bash
git checkout -b 57_add-full-url
git push -u origin 57_add-full-url
# Or
git config --global push.default "current"
git push
```
##
<img src="https://i.imgur.com/lXTXDTB.png" align="center" width=760/>
```bash
git add .
git commit -m "Add full URLs (closes #57)"
```
##
<img src="https://i.imgur.com/FLT3de1.png" align="center" width=760/>
```bash
git commit --amend -m "Agregar URLs completos (closes #57)"
```
##
<img src="https://i.imgur.com/b2Cvwmt.png" align="center" width=760/>
```bash
git reset --hard
```
##
<img src="https://i.imgur.com/5Xs2YEy.png" align="center" width=760/>
```bash
git checkout master
```
##
<img src="https://i.imgur.com/3fW3rwe.png" align="center" width=760/>
```bash
# Agregar el remoto "upstream"
git remote add upstream [email protected]:maurolepore/fgeo.plot.git
```
## Terminal
```bash
git fetch upstream
git checkout master
git rebase upstream/master
```
[Alternative](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow)
##
```bash
# reset ~1 commit
# reset ~2 commits
# reset ~n commits
git reset HEAD~1
```
##
```bash
# ~1 revert ~1 commit
# --no-edit for auto message
git revert HEAD~1 --no-edit
# Revert commit with SHA a867f483
git revert a867f483 --no-edit
```
##
```bash
# Cherry pick commit 63da5bb3
git cherry-pick 63da5bb3
```
##
```bash
# Local
git branch -d a-branch
# Local, force
git branch -D a-branch
# From remote origin
git push -d origin a-branch
# From remote upstream
git push -d upstream a-branch
```
##
```bash
# ~3 manipulate ~3 commits
git rebase -i HEAD~3
# Commands:
# p, pick = use commit
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# ...
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
```
```bash
git rebase --abort
git commit --amend -m "New commit message"
git rebase --continue
```
<https://about.gitlab.com/2018/06/07/keeping-git-commit-history-clean/>