Skip to content

Git and GitHub

Eric Marty edited this page Sep 12, 2023 · 12 revisions

Creating a GitHub Repository for your Drake Lab Project

  • Log in to GitHub.
  • Click on the "New" button.
  • Select DrakeLab as 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 README unchecked if you will be adding your protocol as REAMDE.md later.
  • Leave Add .gitignore: None and Add a license: NONE for now. You can add these later if you need them.
  • click Create Repository

Add Optional Topic Tags

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

If you don't have Git on your computer:

  1. Download it and install it from here: https://git-scm.com/downloads

  2. In RStudio, go to Tools > Global Options Click Git/SVN Click Enable version control interface for RStudio projects You can ignore the part about RSA keys and SSH.

If you've never used Git before, configure git:

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

Set up an RStudio project for your Drake Lab Project and link it to the GitHub Repository

  • Navigate to the home page of your GitHub repository
  • Click the Clone or download button and copy the URL, or copy the URL from the browser's address bar.
    The URL should look something like: https://github.com/DrakeLab/surname-test
  • 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 add 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

Get Working

Proceed to Project Management for tips on how to organize your Rstudio Project folder and how to work with Git.

Make some changes / additions

Add or modify files in your RStudio project.

First "commit"

  • In the Git tab, click the check boxes next to changed or new files you wish to add to the repository. Be sure to add the '.gitignore file the first time.
  • Click commit, enter a Commit message and press the Commit button.

Push

  • to sync your folder with the GitHub repository online, click Push.

Managing images and figures files in git

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.

Managing large datasets in Git

While git-LSF can also be used for large datasets, we recommend DVC for this purpose. Stay tuned for more info.

Lab Links

Clone this wiki locally