Rstudio: Changing origin for git version control of project

user6571411 picture user6571411 · Sep 11, 2016 · Viewed 7.9k times · Source

I originally set up git in Rstudio while enrolled in the Data Scientist's Toolbox course at Coursera. Unfortunately, I did this in my phd project. The repository no longer exists on github. I am now attempting to write my thesis in rmarkdown using knitr and bookdown. I would like to use version control, both to learn proper git workflow and to have a structured back up of everything I have done in my thesis. However, I have been unable to change the version control repository in Rstudio.

  • I am unable to change this in the Tools > Version control > Project setup > Git/SVN menu. The Origin: textbox is unchangable.
  • I tried creating a new project using the old phd project's working directory. This also cloned the version control settings.

How do I change the origin to accomplish what is described above?

Answer

yufree picture yufree · Sep 24, 2016

Git, Github and Rstudio are different things. You could use git as local version control tools. You might connect your local repo to Github account which is based on git by push/pull. Rstudio just makes a user interface for git and supplies the function to push the repo into remote server based on git to make version control(not only Github, but also Gitlab).

So for your issue, if you do not want to pay for github for a private repo, all of your code would be public and I don't think it is good before your finally finished your thesis. But version control could be made locally with git only. Just use git shell to control the version.

However, as a student, github could support private repo here for you. Just register and find your student package. Then just remove the url for remote repo after you cd to your workdir in command line, use the following code to find your remote url(mostly you might fing origin):

git remote -v

Then use this to remove them:

git remote rm origin

Now you could use version control locally. If you want to connect this repo to your remote github private repo, use this:

git remote add origin https://github.com/[YourUsername]/[YourRepoName].git

RStudio would find this information about git and support your following operation. Project in RStudio is different with git, although project support git as version control tool. So you need git in command line or shell to solve your problem.