-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtutorial_notes.qmd
More file actions
163 lines (91 loc) · 7.14 KB
/
Copy pathtutorial_notes.qmd
File metadata and controls
163 lines (91 loc) · 7.14 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
---
title: "git_tutorial_notes"
format: html
editor: visual
---
# Getting started with github, git and R-studio.
### Creating a github account
Go to the github [website](http://github.com)

and signup with your email and password.

Once you have a github site, in the upper left hand corner on your github site create a repository for where you want files from your pending project to go. Name the repository whatever you will be calling your project. Select to have a readme file where you can post notes about the project. Select to make it private while you are working on int (this can be changed later).

Once you hit create you new repository should look something like this:

## Getting started with git on your computer
Check if you have git installed on your computer. For this you have to use terminal to check. In your terminal write
git --version
and you should get back your version number.

If you do not have git on your computer you may have to install it. For instructions on how to check and install git on your computer see this very helpful [website](https://jennybc.github.io/2014-05-12-ubc/ubc-r/session03_git.html) or better yet this [manual](https://happygitwithr.com/index.html)
## Setting up your project in R studio
Now that you have a github account and a local git on your computer you are ready to start working with git through R studio.
Open R-studio and start a new project. Choose a project with version control:

Select the option to clone a repository from git. What R studio will then do is to clone the repository you created on github locally on your computer.

So that R-studio knows which github local repository to clone you have to specify an external url that matches your username and the name of the new repository that you just created on github (Repository URL).
You also have to specify where your local git files are going to be located see (Create project as subdirectory of:).

Hit the create button and R studio will create a project site that should look something like this. Notice how the files replicate what is in

In case you run into trouble at this stage - and are not able to connect your files make sure that your local credentials (signup email matches the email you used to signup with github). To check this you can use:
```{r}
library(usethis)
edit_git_config()
```
Remember that you have to install the "usethis" package if it is not already on your computer.
If your git and hub have no problems communicating you can set about modifying your local files at will, adding files and changing them.

Each time you add a new file in your local directory or change it in some way it will appear in your git tab like so:

Notice that because I have not modified the README file that was imported from github this file does not appear in my git tab.
## Pushing files
The final step is to commit the changes I have made to my local files to the github repository. For this purpose I have to commit the files I want to update (I only commit the files I wish to update) and then I need to push them to the external repository.
To do this I first select the files that I want to commit. Next I hit the commit button.

When I hit the commit button another window pops up where I can write myself notes about the changes I am committing.

Once I hit commit R-studio knows which local files I want to change in my external depository. Note that I can work locally and commit many files and then work on other files and commit them later. The last step then is to push all my committed files to my external repository.
From within my project I simply push the push button in my now empty git tab and my external repository is updated.


Github then tracks all of the changes in each file and new files added in each commit while also updating the main file.
This is very nice if you are working on a project - like a website that you might want to change frequently. You can simply open the project - make a change to any one part of the project and commit those changes to github. Imagine, for example, a website where you post new data and other information as it becomes available.
# Exercise
### Install git on your computer
### Create a github account
### Create a version control project in R studio and upload it to Github
# Working together in git.
\## Working together in git
One of the most useful things about github is the ability to work to
About this section in the tutorial.
Jordan. I am a little confused about this section. It is not clear to me whether this is instructions for associating a new project with git or if this is necessary steps for all projects?
### Associating existing r studio projects with git?
Here you should first note that they still have to create a repository on git but if they then want to associate an existing R-studio project with git these are the steps they should take.
```{r}
#| echo: false
library(usethis)
use_git()
```
Note that after this command they need to respond to a couple of questions with a number selection. Then they should see the git tab.
<!-- Include a note in the quarto tutorial that if the git tab does not appear they may need to install Xcode and homebrew-->
```{r}
#| echo: false
library(usethis)
create_github_token()
```
Note here that when they create this token they are asked to make a number of selections about what this token is for - which ones do they need to mark?
Token: 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
```{r}
library(gitcreds)
gitcreds_set()
```
Change the sentence "You'll enter..." To "You will be prompted to enter (? Enter password or token:)." This will explain where you enter the token.
## Connecting R studio projects and GitHub
I am a little confused here. You say "Sometimes you already have a project ...." Isn't this what we are having them do? Create a project locally and then connect it? Am I understanding you correctly that the process we just went through created the repo on github already? But if we want to take an existing project and put it on github the process in this section explains how to do that? So they should not run this code? If that is the case then perhaps put it in notes in a different way to explain that these instructions are outside the current tutorial.
### Create a project As we discussed this should come first in the tutorial.
##Pushing changes
Explain or show a picture of the committ button. Explain that this brings up a new window where you can commit your changes.
When they are working through this tutorial they will actually get a message that looks like this when they commit: