Create and Clone a Git Repository

This tutorial provides a step-by-step guide for creating repositories on GitHub and cloning them to your local computer. GitHub repositories are remote storage spaces that allow you to track script changes, collaborate with colleagues, and document your research process. Public repositories can also be cloned by others to facilitate reproducibility and collaboration.

Requirements and Necessary Software

Creating a Repository on GitHub

  1. Sign in to GitHub. Click the “+” icon at the top right and select New repository.

  2. Enter repository details:

    • Name your repository and provide a brief description.

    • Choose public or private visibility.

    • Select initialization options.

    • Click Create repository to finish.

Cloning a Repository via Git Bash

  1. Visit the repository you want to clone.

  2. Open Git Bash.

  3. Navigate to the target directory:

    • Use pwd to check your current path.

    • Use cd to move to your preferred folder.

    The path after ~ shows your current location.

  4. Run the clone command:

    git clone https://github.com/ehsanx/EpiMethods.git

Cloning a Repository via RStudio

  1. Go to the GitHub repository and copy the HTTPS URL.


  2. Open RStudio: File > New Project

  3. Select Version Control.

    • Then choose Git.

  4. Complete the Git project setup:

    • Paste the HTTPS link under Repository URL.

    • Optionally, edit the Project directory name.

    • Click Browse to choose a folder (e.g., your Desktop).

    • Click Create Project to finish.

    • The cloned repository will now be available in your selected folder.

Useful Resources