forked from RVerse-Tutorials/RWorkflow-NWFSC-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset-up.Rmd
113 lines (72 loc) · 5.86 KB
/
set-up.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
---
title: "Set-up"
output:
html_document:
toc: true
include:
after_body: footer.html
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Everything you'll be using is free. You will need a GitHub (free) account. Sign up here [GitHub](https://github.com/).
To follow along with the material on your own computer, install the following:
* Install [R](https://cran.r-project.org/)
* Install [RStudio](https://www.rstudio.com/products/rstudio/download/)
* Install [GitHub Desktop](https://desktop.github.com/)
To follow along with RStudio Cloud (with a browser) instead of installing programs (or if you following along on a phone or tablet): Sign up for an [RStudio Cloud](https://rstudio.cloud/) account.
## Git using GitHub Desktop
For the class, I am going to focus on using Git from GitHub Desktop as it is easy to use and does not have the headaches of Git using RStudio.
1. Get a [GitHub](https://github.com/) account
2. Install [GitHub Desktop](https://desktop.github.com/)
3. Open GitHub Desktop, go to Preferences, click Accounts and login to your GitHub account.
4. Still in Preferences, click Git and enter your name and email.
## Git in RStudio Cloud
1. Tell RStudio Cloud you want use Git. Open your project then Click Tools > Global Options > Git/SVN (left nav) and check 'Enable version control for RStudio projects'
{25%}
2. Click the Terminal tab in the lower left panel or click the blue cog below the Git tab in the upper right panel.
{25%}
3. Type in this with your info
```
git config --global user.email "<your email>"
git config --global user.name "<your name>"
```
## Git from RStudio
Pushing to GitHub from RStudio is a hassle because there are many steps to getting the credentials (passwords) properly communicated. These steps are operating system dependent and can especially be hard if you don't have admin access on a PC.
However, you can clone repositories from GitHub and commit your changes (without pushing to GitHub) without having to do credentials. All you need to do is tell RStudio where `git.exe` is on your computer. If your repo is public, you can even pull without RStudio knowing your GitHub password.
### Telling RStudio where `git.exe` is
1. Open RStudio
2. Click Tools > Global Options
3. Click Git/SVN on the left
4. Click the little check box at the top
5. In the Git executible box, paste in the location of `git.exe`
* On a Mac? It is at `/usr/bin/git` Just paste that in.
* On a PC? Look (by opening a finder window) in the following places. Try the GitHubDesktop one first.
* C:/Program Files/Git/bin/git.exe
* C:/Users/your.username/AppData/Local/Programs/Git/bin/git.exe
* C:/Users/your.username/AppData/Local/GitHubDesktop/app-2.8.3/resources/app/git/cmd/git.exe
6. Restart R. Session > Restart R...
### Telling RStudio your GitHub username and password
You only need this if you will be pushing to GitHub or have a private repo and are pulling. Everything else works fine without your password.
See the [2020 Set-up instructions](https://rverse-tutorials.github.io/RWorkflow-NWFSC-2020/set-up.html#Set_up_RStudio_to_use_Git) and go to the part about setting up your credentials. I won't be covering this in 2021.
<!--
### NWFSC staff
**GitHub** If you are using GitHub in a work capacity, as opposed to purely non-work or school, then the repositories you post should be intended for public use (as opposed to just a personal repo). GitHub is officially allowed for a platform for release of products and provides a nice platform for that. I'll show a few examples. There is paperwork to fill out [info](https://docs.google.com/document/d/1KFajoHazgpm55c1wlGeaaq0gRKVoQviAK0yurOQNr8c/view) and [checklist](https://drive.google.com/file/d/0B6s8nwvlch0hZ0VWR01rVmtuUGs/view). Key point is that GitHub is not NOAA-controlled and sensitive information and data that needs to stay on government computers should not be on GitHub.
**GitHub internal server** If you want to have repositories for work that is not intended for the public or that involve data, code, or reports that cannot be on a non-NOAA computer, then you can use the NWFSC GitHub server. Contact Marcus Nedelmann at NWFSC to get an account. No paperwork needed.
### Non-NOAA participants or those using GitHub purely for non-NOAA work
If you don't already have an account on GitHub, go to [github.com](https://github.com) and click the "sign up" link near upper right of the page. It is pretty self-explanatory. Go ahead and get a **free** account. The free GitHub account allows you to have unlimited public and private repositories.
## Week 3: Installing packages from GitHub
Windows people: You will need to install [Rtools](https://cran.r-project.org/bin/windows/Rtools/history.html).
Run this code to confirm that you can install packages from GitHub:
```{r get-packages-from-github, eval=FALSE}
devtools::install_github("RVerse-Tutorials/TestPackage")
```
To install from an internal GitHub server, like the NWFSC GitHub, use this. Note for the NWFSC GitHub, you need to be on the network since this is an internal (not public) server. Again, replace the dummy variables with the real values.
```{r get-packages-from-gitlab2, eval=FALSE}
devtools::install_github("<github account>/repo name", host="<url of the server>")
```
## (Optional) Packages with C++ code
We will not be doing this, but often you will want to install packages with C++ code. To do that, you will need Rtools (Windows) or Xcode (Mac)
* **Rtools** Windows users [Rtools](https://cran.r-project.org/bin/windows/Rtools/) also so you can build packages with C++ code if needed. See comments here about changing path. [Rtools](http://stat545.com/packages01_system-prep.html#windows-system-prep)
* **Xcode** Mac users Open terminal and type the following command `xcode-select --install`
-->