Step 1: Make a GitHub account
Create a GitHub account (if you do not already have one): https://github.com/ - this is completely free to use. Please email the instructors the username for your account.
Step 2: Installing and configuring Git
If you do not have Git installed, install it from here: https://git-scm.com/downloads.
You may already have Git installed without knowing it, please read the directions available from the definitive guide on R
and Git / GitHub: https://happygitwithr.com/install-git.html. You may have to access your shell (aka terminal, command prompt, etc). DO NOT PANIC. You can read more about the shell here: https://happygitwithr.com/shell.html#shell, with instructions depending on your operating system.
After installation, you will need to configure Git (read more about it here: https://happygitwithr.com/hello-git.html). You can use the shell for this, or you can do this directly in R
:
# Uncomment the following line to install the usethis package:
# install.packages("usethis")
library(usethis)
use_git_config(user.name = "Your Name", user.email = "your-github@email.address")
Use your full name for the user.name
field and then use the same email as your GitHub account for user.email
.
Step 3: Create repository with GitHub
We will follow the paradigm of “GitHub
first”. What this means is that when we create a repository, we will create it on GitHub
first, then link a local repository to it from inside RStudio
.
In GitHub
, do the following:
go to the top-level directory (i.e., github.com/<your user name here>
)
click on “+” at top right, and select “New repository”
name the repository (e.g., “cmsacamp-eda-project”)
provide a short description of the repository (don’t leave completely blank!)
keep the repository public
click on “Initialize this repository with a README”…there is no need to “Add .gitignore” or “Add a license”
click on “Create Repository”
Step 4: ..then in RStudio
In RStudio
, do the following:
click on File > New Project...
click on “Version Control”, then on “Git”
provide the full address for the “Repository URL” (including the https
, etc.; by default, this will provide the name of your local repository)
make sure “Create project as subdirectory of:” points to where you want to point it
click on “Create Project”
At this point, you should find that your Files
pane is listing the files in your local repository, including one ending in .Rproj
and the README.md
file that was created on GitHub
.
Step 5: Updating your repository
To, e.g., add a new file to your local repository, do the following:
open the new file as you always would (as an R Script
, an R Markdown
file, etc.)
fill the file with “stuff”
save the file…at this point, the file name should show up in the Git
pane next to an “M” symbol (for modified)
continue to modify the file, or…stage the file for a commit (think of it as: pose it for its snapshot) by clicking on “Staged” in the Git pane
click on “Commit” in the Git
pane
in the new window that opens, add a “Commit message”, then click on the “Commit” button
click on “Push” to push your changes from your local repo to your GitHub
repo
If you encountered no errors then you’re done! While working on a single project you will repeatedly use Step 5, update file, commit changes, then push changes. We will cover pulling at a later time.
Every time you want to create a new repository, you can just start with Step 3, use GitHub, copy the repository into RStudio, then repeatedly update, commit, and push.
Email the instructors if you have any questions.
LS0tCnRpdGxlOiAiU2V0dGluZyB1cCBHaXRIdWIiCm91dHB1dDogaHRtbF9kb2N1bWVudAotLS0KCmBgYHtyIHNldHVwLCBpbmNsdWRlPUZBTFNFfQprbml0cjo6b3B0c19jaHVuayRzZXQoZWNobyA9IFRSVUUpCmBgYAoKIyMgU3RlcCAxOiBNYWtlIGEgR2l0SHViIGFjY291bnQKCkNyZWF0ZSBhIFtHaXRIdWJdKGh0dHBzOi8vZ2l0aHViLmNvbS8pIGFjY291bnQgKGlmIHlvdSBkbyBub3QgYWxyZWFkeSBoYXZlIG9uZSk6IFtodHRwczovL2dpdGh1Yi5jb20vXShodHRwczovL2dpdGh1Yi5jb20vKSAtIHRoaXMgaXMgY29tcGxldGVseSBmcmVlIHRvIHVzZS4gUGxlYXNlCmVtYWlsIHRoZSBpbnN0cnVjdG9ycyB0aGUgdXNlcm5hbWUgZm9yIHlvdXIgYWNjb3VudC4KCiMjIFN0ZXAgMjogSW5zdGFsbGluZyBhbmQgY29uZmlndXJpbmcgR2l0CgpJZiB5b3UgZG8gbm90IGhhdmUgR2l0IGluc3RhbGxlZCwgaW5zdGFsbCBpdCBmcm9tIGhlcmU6IFtodHRwczovL2dpdC1zY20uY29tL2Rvd25sb2Fkc10oaHR0cHM6Ly9naXQtc2NtLmNvbS9kb3dubG9hZHMpLgoKWW91IG1heSBhbHJlYWR5IGhhdmUgR2l0IGluc3RhbGxlZCB3aXRob3V0IGtub3dpbmcgaXQsIF9fcGxlYXNlIHJlYWQgdGhlIGRpcmVjdGlvbnMgYXZhaWxhYmxlIGZyb20gdGhlIGRlZmluaXRpdmUgZ3VpZGUgb24gYFJgIGFuZCBHaXQgLyBHaXRIdWJfXzogW2h0dHBzOi8vaGF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