-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-rstudio-practical.qmd
More file actions
192 lines (140 loc) · 4.43 KB
/
git-rstudio-practical.qmd
File metadata and controls
192 lines (140 loc) · 4.43 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
---
email: "[stephen.gregory@cefas.gov.uk](mailto:stephen.gregory@cefas.gov.uk)"
format:
revealjs:
theme: custom.scss
incremental: false # true
from: markdown+emoji
execute:
eval: true
echo: false
message: false
warning: false
code-fold: true
code-summary: "expand for full code"
fig-align: "center"
embed-resources: true
lightbox: true
---
## {background-image="background-title.png" background-size="100%"}
::: {.absolute top="0%" left="0%" width="1100" style="font-size: 1.75em; color: #1C2442; font-weight: bold;"}
Using [`git`](http://git-scm.com/) in [`RStudio`](https://www.rstudio.com/)
:::
::: {.absolute top="15%" left="0%" width="1100" style="font-size: 1.25em; color: #00AAB4;"}
Stephen, Jennifer, Tiago & David
:::
```{r setup}
#| include: false
# libraries
library(here)
# do a sum
a <- 1 + 1
print(a)
```
## Setup {background-image="background-body.png" background-size="100%"}
:::: {.columns}
::: {.column width="75%"}
* Assume `R`, `RStudio` & `git` installed & working together
- [If not, see Appendix]{.small-text}
* Create a [`GitHub`](http://github.com/) account
* Create a repository ("repo") on `GitHub`
* `clone` the repo as an `RStudio` project
* Write a `README.md` using markdown
:::
::: {.column width="25%"}

:::
::::
## Regular use {background-image="background-body.png" background-size="100%"}
:::: {.columns}
::: {.column}
::: {.small-text}
**Step 1** Click *Pull* on *Git panel*
:::
* Create, edit, modify, e.g., R scripts, then:
::: {.small-text}
**Step 2** Click *Commit* on *Git panel*
**Step 3** Check boxes to *Stage* changes to commit
**Step 4** Write *Commit message* & click *Commit*
**Step 5** Once committed, don't forget to *Push*
:::
* Changes visible on `GitHub` :sweat_smile:
:::
::: {.column}

:::
::::
## Other options in [`RStudio`](https://www.rstudio.com/)
:::: {.columns}
::: {.column width="40%"}


:::
::: {.column width="60%"}
::: {.small-text}
* **Diff** opens *Git window* with output of `git diff <file>` of choosen file
* **Commit** opens *Git window* is where we stage and commit changes to files
* **Pull** does a `git pull` (also accessible from *Git window*)
* **Push** does a `git push` (also accessible from *Git window*)
* **History** opens a window with output of `git log`
::: {.callout-important title="Go directly to `bash` and don't pass go"}
By now, you've exhausted `git` options in `RStudio`: use `bash`!
:::
* **More** menu allows access to `git revert` & add files to `.gitignore`
* Create and checkout a *Branch* using buttons on the RHS
:::
:::
::::
<!-- ## {background-image="close_bg.png" background-size="100%"} -->
<!-- ::: {.absolute top="44%" left="53%" width="150"} -->
<!-- {{< meta email >}} -->
<!-- ::: -->
## Appendix {background-image="background-body.png" background-size="100%"}
## Install [`R`](https://www.r-project.org/) on Windows
:::: {.columns}
::: {.column}
* Visit the [`R`](https://www.r-project.org/) website
* Follow the links to `download R`, incl. select mirror and OS
* Double click installer and follow instructions
* Install required packages with `install.packages()`
:::
::: {.column}

:::
::::
## Install [`RStudio`](https://posit.co/products/open-source/rstudio/) on Windows
:::: {.columns}
::: {.column}
* Download [`RStudio`](https://posit.co/download/rstudio-desktop/) installer
* Double click installer and follow instructions
:::
::: {.column}

:::
::::
## Install [`git`](http://git-scm.com/) on Windows
:::: {.columns}
::: {.column}
* Download [`git`](http://git-scm.com/), currently v 2.45.2
* Double click installer and follow instructions
::: {.callout-important title="Installation location"}
Note the location where `git` is installed, e.g.
`C:\Users\{...}\AppData\Local\Programs\`
:::
<!-- * At "Choose the default behaviour of `git pull`": select `Rebase` -->
* Set `git` configurations, e.g., `user.name`, `user.email`, etc.
:::
::: {.column}

:::
::::
## Getting them to work together
:::: {.columns}
::: {.column}
* [`git`](http://git-scm.com/) authentication is OS-specific - see David's slides
* Connect `RStudio` and `git`: Tools > Global Options... > Git/SVN
:::
::: {.column}

:::
::::