::create_github_token() usethis
1 Introduction to Github
Walk through what I’ve learned in a step by step instructions format.
Overview of Github, what it is and why people use it
Steps to set up Github to connect with local RStudio.
Steps to fork and pull request with other people’s repos. Conventions with branching and updating fork.
How Github will tie into my future work.
1.1 Install Git
Check if Git is already installed
- Open terminal/shell.
- Type the following commands:
which git
and
git --version
- If there see a path (e.g.,
/usr/bin/git
) and a version number, Git is already installed.
If the output is something like git: command not found
, Git must be installed following the below.
1.1.1 Windows
Download and install Git for Windows here: https://git-scm.com/download/win
1.1.2 macOS
- Open the terminal.
- Type either of the following commands to prompt an offer to install:
git --version
or
git config
Accept the prompt and click “install.”
- Or request installation with
xcode-select --install
1.2 Connect GitHub account to local
Must connect GitHub account for Git to associate commits with the correct name and email.
- Open terminal/shell.
- Set name and email (replace with individual GitHub info):
git config --global user.name "Jane Doe"
git config --global user.email "jane@example.com"
git config --global --list
- Confirm that it worked with
git config --global --list
1.3 Set Up HTTPS Personal Access Token
When interacting with GitHub, Git needs to verify identity. This requires credentials, and GitHub now requires a Personal Access Token (PAT).
1.3.1 Generate PAT
Option 1: In browser
- Go to: https://github.com/settings/tokens
- Click “Generate token”
- Choose scopes (recommended:
repo
,user
,workflow
) - Click “Generate token” again
- Copy the generated token (starts with
ghp_...
)
Option 2: From R
1.3.2 Set and Save PAT
In R, call
::gitcreds_set() gitcreds
Paste the PAT in response to the console output:
: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
? Enter password or token-> Adding new credentials...
-> Removing credentials from cache...
-> Done.