Introduction

This file covers how to set up, enable, and troubleshoot Github

# install.packages("tidyverse") 
# install.packages("knitr")
# install.packages("usethis")
library("tidyverse") 
library("knitr")
library(usethis)
# Github

Github setup (run in console)

# Get git credentials
credentials::git_credential_ask()  
## $protocol
## [1] "https"
## 
## $host
## [1] "github.com"
## 
## $username
## [1] "RyanWaln"
## 
## $password
## [1] "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"
## 
## attr(,"class")
## [1] "git_credential"
# see Git status
usethis::git_sitrep()
## Error:
## ! repository path 'E:/Tri 2 2026/Techniques in Marine Science 1/Programming_Data_Analysis' is not owned by current user
# force usb to be recognized as safe directory by opening up .gitconfig file
usethis::edit_git_config()

Ensure .gitconfig file has these lines of code:

[user] email = name = Ryan Waln [safe] directory = E:/ directory = D:/

# Then restart R and run 
usethis::git_sitrep() 
## Error:
## ! repository path 'E:/Tri 2 2026/Techniques in Marine Science 1/Programming_Data_Analysis' is not owned by current user
# Additional troubleshooting below

# set up credentials if git failed to load them
usethis::use_git_config(
  user.name = "Ryan Waln",
  user.email = "ryan.waln@aol.com")

# create Personal Access Token
usethis::create_github_token() 

# prompt to insert PAT
gitcreds::gitcreds_set() 
## Error in `throw()`:
## ! `gitcreds_set()` only works in interactive sessions

Workflow for github:

Edit → Save → Stage → Commit → Pull → Push

#track current project locally (can also use Tools > Project Options … > Git/SVN, and set to Git)
usethis::use_git() 
## Error:
## ! repository path 'E:/Tri 2 2026/Techniques in Marine Science 1/Programming_Data_Analysis' is not owned by current user
# Have github start tracking files
usethis::use_github() 
## Error:
## ! repository path 'E:/Tri 2 2026/Techniques in Marine Science 1/Programming_Data_Analysis' is not owned by current user
# Execute other r script such as workshop 1 R script (doesn’t work with R markdown files)
source("../Code/Workshop_1.R")
## Error in `-rm(list = ls())`:
## ! invalid argument to unary operator