Begin Working in a Git Repository


Scope

This page summarizes how you can begin working in a Git repository. It covers both the process of creating a new Git repository or beginning work in an existing Git repository.

Initializing a New Git Repository

Described below are two basic ways to initialize a Git repository, either via Command Line Interface (CLI) or the RStudio IDE.

CLI

git init

The command above will initialize an empty Git repository in your current working directory and create a hidden .git folder

RStudio

To create a new Git Repository via the RStudio IDE:

  • Click on the icon for creating a new R project
  • Select the type
  • Then check the box that says Create a Git repository.

Creating a Git Repository via RStudio

Cloning an Existing Git Repository

Starting work on an existing Git repository will involve cloning an exact copy of that repository onto your computer.

Below are descriptions of how this can be done either via Command Line Interface (CLI) or the RStudio IDE.

CLI

Navigate to the directory you want to clone the repository in then in your Terminal call:

git clone <url>

You may be prompted to type in your username or password if it's not a publicly accessible repository.

RStudio

To clone an existing Git Repository via the RStudio IDE:

  • Click on the icon for creating a new R project
  • Select Version Control
  • Select Git
  • Then fill out the information as it pertains to the existing repository.

This process is covered in more detail here.

Cloning a Git Repository via RStudio