How to link an existing RStudio Project with Git?

0

 Here are the steps on how to set up a local project that isn't under version control:

  • Open RStudio.
  • Click on File > New Project.
  • Select New Directory.
  • Give your project a name.
  • Click on Create Project.
  • Do not click on Create a Git Repository.
  • Open a Git Bash terminal and navigate to the directory where your project is located:
    • cd ~/dir/name/of/path/to/file
  • Run the following commands:
    • git init
    • git add .
    • git commit -m "Initial commit"

  • Go to GitHub.com and sign in to your account.
  • In the top right corner of the page, click the New Repository button.
  • In the Repository Name field, type the exact same name as your R project.
  • Leave the Initialize this repository with a README checkbox unchecked.
  • Click the Create Repository button.

Upon creating the repository, you should see a page like this:


You should see that there is an option to “Push an existing repository from the command line” with instructions below containing code on how to do so. In Git Bash copy and paste these lines of code to link your repository with GitHub. Now the Git Bash new repository is uploaded the file into the GitHub

When you re-open your project in RStudio, you should now have access to the Git tab in the upper right quadrant and can push to GitHub from within RStudio any future changes.

Working on an existing GitHub repository

Here are the steps on how to clone an existing project from GitHub, from within RStudio:
  • Open RStudio.
  • Click on File > New Project.
  • In the New Project window, select Version Control > Git.
  • In the URL field, enter the URL of the GitHub repository that you want to clone.
  • In the Project directory field, enter a location on your computer where you want to store the cloned repository.
  • Click on Create Project.
RStudio will now clone the GitHub repository to your local computer. Once the cloning process is complete, you will be able to access the files in the repository from within RStudio.

Post a Comment

0Comments
Post a Comment (0)