-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasics.qmd
70 lines (43 loc) · 4 KB
/
basics.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
# The basics of GitHub
## Getting started
### Installing Git
[Here](https://github.com/git-guides/install-git) is a general guide for installing git for the different operating software.
- for windows
- for MacOS
- for Linux
### Setting up
If you don't already have one create a [GitHub](https://github.com/) account.
::: {.callout-note}
If you are a university student you qualify for a [free pro account](https://education.github.com/pack)
:::
### Talking to git
Now that you have installed `git` you need to link it to your GitHub account and make sure that the two are able to 'talk' to each other. Again there are many ways to set this up. We will discuss some of these approaches below.
#### Linking with Terminal
##### Connecting over HTTPS (recommended)
If you clone with HTTPS, you can cache your GitHub credentials in Git using a credential helper. For more information, see About remote repositories and Caching your GitHub credentials in Git.
##### Connecting over SSH
If you clone with SSH, you must generate SSH keys on each computer you use to push or pull from GitHub. For more information, see About remote repositories and Generating a new SSH key and adding it to the ssh-agent.
#### Linking with RStudio
1. **Tell RStudio where to find the git programme**: Under the Tools menu, open Global Options and go to the Git/SVN section. Then enable the version control interface and make sure RStudio knows where to find git. For MacOS, enter the path (which you can find by typing `which git` into your terminal), for Windows, find the git program in your Program Files.
2. **Configure Git**: The easiest way to do this is in `R` through the `{usethis}` package. and you can just run usethis::use_git_config(user.name="Jane Doe", user.email="jane@example.org") in your R console. Replace with your name and the email that is linked to your GitHub account
3. **Link your GitHub account**: Now you need to link your GitHub account/credentials. The path of least resistance is going the HTTPS, personal access token (PAT) route. [{usethis}](https://happygitwithr.com/https-pat) package, which outlines how to get a PAT and link that to your git credentials.
#### Linking with VSCode
To get started with the GitHub in VS Code, you'll need to create an account and install the [GitHub Pull Requests and Issues extension](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github). Once you have installed the extension, you will need to sign in. Follow the prompts to authenticate with GitHub and return to VS Code.
::: {.column-margin}
![#94: professortocat_v2 *© GitHub, Inc.*](assets/octocats/Professortocat_v2.png)
:::
## Understanding the version control workflow
### Key terms
repo - short for repository
repository - the directory or folder that is under version control
local - the repository on your computer
remote - the repository on GitHub
commit - take a snapshot of one or more files in the repository
push - send commits from the local repo to the remote repo
pull - retrieve commits from the remote repo to the local repo
.gitignore a file that tells git which files or types of files you don’t want to commit
Let’s start by briefly explaining the basic workflow. On GitHub you can make repositories, which is a kind of project. Your online repository, or short repo, is called remote. To use your repository, you need to clone it locally onto your computer and it is then called local. You can write and edit R code locally on your computer. The new code is then committed and pushed back to the remote. If you follow this workflow consistently, GitHub will keep track of all the changes you make.
![This is the basic github workflow. First we need to retrieve the remote version of repository. We now have an exact copy of the online repository locally. We are then free to work on and develop the files that are in the repository. Once we have made our changes we need to send these back to the remote repository.](assets/workflows/github_basic.png)
## References {.unnumbered}
::: {#refs}
:::