Creating a PAT and storing it in the server

To store your personal access token (PAT) in the server:

Creating a PAT

1. Get to the GitHub PAT creation website

On the GitHub website navigate to:

  • settings
  • developer settings (last option on the left)
  • Personal access tokens
  • tokens (classic)
  • generate new token button (classic) (near right corner)

Click on: Generate new token (classic)

2. Select options and generate PAT

Select the following options:

Note: this is the same process as using usethis::create_github_token from an R console outlined in the MEDS installation guide. Here we selected the same options for the PAT as given by usethis::create_github_token.

Click on: Generate token

3. Temporarily save the PAT

Copy and paste the PAT somewhere for now! You will need to use it when pushing for the first time. After this, you should delete that note where you temporariliy wrote down the PAT.


Storing a PAT in the server

1. Have a PAT ready

If you already have a PAT that you can copy paste, you can skip to step 2. Otherwise, create or regenerate one. Otherwise, you can follow the instructions above or regenerate one directly through GitHub.

2. Set up the git credential helper

  1. Using the terminal, navigate to the directory from where you want to push your updates. Make sure you are on that directory (for example, verify you are on the eds220-in-class by running pwd on the terminal).

  2. Run the following command on the terminal:

git config --global credential.helper store

This indicates to git that you want to store the PAT instead of caching it.

  1. Run git config --global --list on the terminal. You should see something like this as the output:
user.name=carmengg
user.email=c_galazgarcia@ucsb.edu
credential.helper=store

That last line indicates that the credential helper is now store.

3. Complete a push

Go through the steps to make a push. Git will prompt you for your credentials, use your GitHub username and use the PAT as the password. Press enter and finalize the push!

4. Verify credentials

  1. Go to your user’s home directory by running cd ~.

  2. Run more .git-credentials. You should see something like this as the output:

https://carmengg:ghp_XTWwWrEtGfL45iIgU6PPDFd990ceIYydqY@github.com

This means your PAT is now stored (the PAT here is an example).

Git should have now stored your PAT on the server!

Mona Lovelace by heyhayhay. Octocat is a registered trademark of GitHub, Inc.; the octocat images are not covered by this website’s CC BY-NC 4.0 license.