-
Notifications
You must be signed in to change notification settings - Fork 0
Git and GitHub
Page Editor: @allopole
To request edits to this page, open an issue, and tag @allopole
- Log in to GitHub.
- Click on the "New" button.
- Select
DrakeLabas the owner. - Enter a repository name following our project naming conventions.
- Enter the full project name as the Description.
- Select
Private - Leave
Initialize this repository with a READMEunchecked if you will be adding your protocol asREAMDE.mdlater. - Leave
Add .gitignore: NoneandAdd a license: NONEfor now. You can add these later if you need them. - click
Create Repository
After you have created your repository, you may add Topic Tags to help people search for your project by topic. To add topics, click on manage topics under the description:
...
List of suggested topics:
- ews
- zika
- malaria
- simulation
- We will eventually have a full list of topics here
-
Download it and install it from here: https://git-scm.com/downloads
-
In RStudio, go to
Tools > Global OptionsClickGit/SVNClickEnable version control interface for RStudio projectsYou can ignore the part about RSA keys and SSH.
Open the a terminal on your computer and run the following 2 commands (you can paste them into the terminal):
git config --global user.name 'Full Name'
git config --global user.email 'myid@uga.edu'
On a Mac, you can have Keychain remember your github password by running the following terminal command:
git config --global credential.helper osxkeychain
The password that you use to login to GitHub’s website is NOT an acceptable credential when interacting with a repository via git/Rstudio (clone, push, pull, etc.). This was possible in the past, but now a PAT is required in place of a password for any git operations.
You have 2 options for creating a PAT.
-
Go to https://github.com/settings/tokens and click “Generate token”.
-
From R, do:
usethis::create_github_token()
create_github_token() will take you to the same Github token generation page.
PATs are like passwords, but are limited in scope. When creating a PAT on GitHub, you will be asked to select "scopes." Recommended scopes to select in GitHub are “repo”, “user”, and “workflow”. Recommended scopes will be pre-selected if you used create_github_token().
Click “Generate token”.
Copy the generated PAT to your clipboard. Or leave that browser window open and available for a little while, so you can come back to copy the PAT.
Provide this PAT in place of a password next time git or Rstudio for your GitHub password. Even though you are asked for a "password," you MUST provide the PAT in place of the password.
You may also store your PAT so R/Rstudio remembers it. In R, call gitcreds::gitcreds_set() to get a prompt where you can paste your PAT:
> gitcreds::gitcreds_set()
? Enter password or token: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-> Adding new credentials...
-> Removing credentials from cache...
-> Done.
Navigate to the home page of your GitHub repository
Click the <>Code button, then HTTPS, and copy the URL (or copy the URL from the browser's address bar and add .git).
The URL should look something like: https://github.com/DrakeLab/surname-test.git
Now, do one of the following:
- Open a terminal on your computer. In the terminal, change directories to the directory you want your project to be. (You'll be creating a brand new copy of your project there.)
cd path/to/directory
- "Clone" the repository using the following command:
git clone "https://github.com/DrakeLab/surname-test.git"
Be sure to include the .git extension at the end of the URL. You should now have a copy of the repository as a folder on your computer.
- In RStudio,
File > New Project... - Choose
Existing Directory - Browse to find the folder you just created, and click
Create Project
- Clone the repository from within RStudio:
- In RStudio
File > New Project... - Choose
Version Control - Choose
Git - Paste the URL into the
Repository URLbox:https://github.com/DrakeLab/surname-test.git - You may change the project directory name and directory location or leave the defaults.
- click
Create Project
Proceed to Project Management for tips on how to organize your Rstudio Project folder and how to work with Git.
Add or modify files in your RStudio project.
- In the
Gittab, click the check boxes next to changed or new files you wish to add to the repository. Be sure to add the '.gitignorefile the first time. - Click
commit, enter aCommit messageand press theCommitbutton.
- to sync your folder with the GitHub repository online, click
Push.
If exported figures are included in a git repository, the exported images should be tracked with git-lfs (Git Large File Storage). "Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise." Follow the instructions to install git-lfs, add lfs to your repository, and specify which file types or folders to track with lfs. Thereafter, lfs works invisibly and you simply commit and push changes as usual. Note: git-lfs is useful for tracking large data files as well as graphics.
While git-LSF can also be used for large datasets, we recommend DVC for this purpose. Stay tuned for more info.
- journal-club doc
- google-sites lab manual
- index of all Drake-lab google sites
- lab-meeting--minutes doc Contact John if you are having trouble accessing google docs or websites.
- repository of public domain images


