# Older than 4.0.0? Update! R.version.string
A Beginnerās Guide to Version Control
š®hilaan šlzahawļøi ā š®tanford šenter for šŖpen and āeproducible š®cience
What are some challenges associated with Git/GitHub? Why would you not use version control?
# Step 1: Install the usethis package
install.packages("usethis")
# Step 2: Load the usethis package
library(usethis)
# Step 3: Set your Git user name and email (must be the email associated with your GitHub account!)
## Option 1, code only: use_git_config()
use_git_config(user.name = "My Preferred Name", user.email = "same_as_my_github@email.com")
## Option 2, point and click: edit_git_config()
edit_git_config() #opens gitconfig file; now, add name and email
Every time you finish a valuable chunk of work
āThe fundamental unit of work in Git is a commit. A commit takes a snapshot of your code at a specified point in time. Using a Git commit is like using anchors and other protection when climbing. If youāre crossing a dangerous rock face, you want to make sure youāve used protection to catch you if you fall. Commits play a similar role: if you make a mistake, you canāt fall past the previous commit.
Like rock climbing protection, you want to be judicious in your use of commits. Committing too frequently will slow your progress; use more commits when youāre in uncertain or dangerous territory. Commits are also helpful to others, because they show your journey, not just the destination.ā (Hadley Wickham & Jenny Bryan in R Packages Ch. 18: Git and GitHub)
Log in to github.com
Create a new repository (click the large green New button)
Show screenshot
Open your new repository and click the large green Code button
Copy the Clone HTTPS URL to your clipboard
Show screenshot
Start a new Project in RStudio
Open your RStudio project and make local changes
Find the Git tab in the upper right pane
Show screenshot
Check the Staged box for the files you want to commit
Click Commit, type an informative Commit message and commit!
Show screenshot
Simply click ā¬ļø Push to push your local changes to your GitHub remote
Show screenshot
Confirm that the local changes are now in your GitHub remote
Show screenshot
Keep in mind:
Open the Diff window (New text = light green, removed text = light red)
Click Discard chunk to undo a block of changes
Show screenshot
Click Discard line to undo changes to individual lines
Show screenshot
Ignoring files
Questions and/or feedback? Reach out to me!