2022 DSS Bootcamp
Colin Rundel
08-25-22
To get everyone on the same page:
A few suggestions on picking a GitHub username:
Incorporate your actual name! People like to know who they’re dealing with. It makes your username easier for people to guess or remember.
Pick a username you will be comfortable revealing to your future boss.
Shorter is better than longer.
Be as unique as possible in as few characters as possible. In some settings GitHub auto-completes or suggests usernames.
Make it timeless. Don’t highlight your current university, employer, or place of residence.
Avoid words laden with special meaning in programming.
To get started as quickly as possible, the preferred method is to use DSS RStudio server(s).
To access RStudio Workbench:
If you are having trouble accessing RStudio Workbench see the next slide.
If you cannot access RStudio via the DSS servers:
Make sure you are not using a custom DNS server
1.1.1.1
or 8.8.8.8
Use a Docker container from Duke OIT
Reserve a Container
and find RStudio - statistics application with Rmarkdown and knitr support
Install R and RStudio locally on your computer
Everything from this computing bootcamp is available at dukestatsci.github.io/computing_bootcamp_2022/
GitHub repo is available at github.com/dukestatsci/computing_bootcamp_2022
You’ll learn how to get this on your computer shortly.
Simple formal system for tracking changes to a project over time
Time machine for your projects
Learning curve can be a bit steep, but when you need it you REALLY need it
Distributed
Popular and Successful
Tracks any type of file
Branching
git is already set-up on the DSS server(s). In the terminal tab you can verify this by running:
Within R we can also use the usethis
package to get a helpful summary of the current git configuration,
usethis::git_sitrep()
## Git config (global)
## ● Name: <unset>
## ● Email: <unset>
## ● Vaccinated: FALSE
## ℹ See `?git_vaccinate` to learn more
## ℹ Defaulting to https Git protocol
## ● Default Git protocol: 'https'
## GitHub
## ● Default GitHub host: 'https://github.com'
## ● Personal access token for 'https://github.com': <unset>
## x Call `gh_token_help()` for help configuring a token
## Git repo for current project
## ℹ No active usethis project
The following will tell git who you are, and other common configuration tasks.
usethis::use_git_config(
user.name = "Colin Rundel",
user.email = "rundel@gmail.com",
push.default = "simple"
)
You will need to do this configuration once on each machine in which you use git (e.g. the server and your laptop).
This can also be done via the terminal with,
To verify you configured git correctly, run
usethis::git_sitrep()
## Git config (global)
## ● Name: 'Colin Rundel'
## ● Email: 'rundel@gmail.com'
## ● Vaccinated: FALSE
## ℹ See `?git_vaccinate` to learn more
## ● Default Git protocol: 'https'
## GitHub
## ● Default GitHub host: 'https://github.com'
## ● Personal access token for 'https://github.com': <unset>
## x Call `gh_token_help()` for help configuring a token
## Git repo for current project
## ℹ No active usethis project
You should see output similar to above with your details.
We will be authenticating with GitHub using SSH via public / private keys. We can create a new key pair (if necessary) by running the following in RStudio’s console:
## No SSH key found. Generate one now?
##
## 1: Yes
## 2: No
##
## Selection: 1
## Generating new RSA keyspair at: /home/guest/.ssh/id_rsa
## Your public key:
##
## ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/wH7pT3UXdOMJSX2wMaPVTyGnYkS8OPmcfjct6h8Q+44/9UG3sOibjjUCxIxVeCWAoYFB0rDI3/Ljf2EWozLlpeGzAe7xsg6A+MHtUObZnfzXSB/NnOhZymD2u8Nh+py07aojVdKAPBkRH3nHA+rljidc3gXZkqseetYEI1N79OQUshp2P+Qm6Vab4I5OCnfAwLFkR7Sw7J9hvZN1qUmM0DB0WTWSlNmPSMsASMe/6Nz30IRoBh35Z7tgF79rlIW385giCkEeD20Le9EOueGoTWarJWylE1RWnUyig2mZ9JK/rYTw4KBXacPhBwn+MgGC+r8xY5IEX78xkeXW9q2z #<<
##
## Please copy the line above to GitHub: https://github.com/settings/ssh/new
## Would you like to open a browser now?
##
## 1: Yes
## 2: No
##
## Selection: 1
In order to get started, you need to obtain today’s files from GitHub. The steps below will give you access.
Log in to GitHub
Navigate to github.com/dukestatsci/computing_bootcamp_2022
Fork the repository
Copy the link under Clone or Download
to clone with SSH.
In RStudio go to File > New Project > Version Control > Git
Paste the URL, that you copied in step 4, in the box under Repository URL
You now should have all the files in the repository in a directory on the server or your own computer.
status
- returns details about the current status of your git repository
add
/ rm
- stage (or unstage) a local file with changes so that the changes will be saved when you commit.
restore
- revert local changes that have not yet been committed
commit
- save staged local changes
push
- send local committed changes to a remote git instance
pull
- collect committed changes from a remote git instance
We will now make sure that everything is working correctly by making changes to the README.md
file in the repository.
Make a small change to README.md
(i.e. add you name) and save the file.
Stage & commit that change using RStudio’s git GUI
Push the changes to GitHub
Check that the changes are reflected on GitHub
Commit early, often, and with complete code.
Write clear and concise commit messages.
Test code before you commit.
Use branches.
Communicate with your team.
git’s Pro Git book, Chapters Getting Started and Git Basics will be most useful if you are new to git and GitHub
Git cheatsheet by Atlassian
GitHub’s interactive tutorial
Free online course from Udacity
Happy Git with R by Jenny Bryan