Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rstudio: Changing origin for git version control of project

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?

like image 700
user6571411 Avatar asked Sep 11 '16 10:09

user6571411


People also ask

How do I change Git origin in RStudio?

This can be done by opening /your. project/. git/config and editing the remote origin line(s), e.g. changing from git to https. Restart Rstudio & you'll be prompted for your github username & password.

Can Git be used for version control?

Git is an open source distributed version control system that helps software teams create projects of all sizes with efficiency, speed, and asynchronicity.


Video Answer


3 Answers

This can be done by opening /your.project/.git/config and editing the remote origin line(s), e.g. changing from git to https. Restart Rstudio & you'll be prompted for your github username & password.

like image 131
dez93_2000 Avatar answered Oct 19 '22 16:10

dez93_2000


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.

like image 21
yufree Avatar answered Oct 19 '22 16:10

yufree


This is what worked for me for migrating from github to Azure

Go to the top right Git window in RStudio and click on the gear. Now click Shell (to open the terminal there).

#remove origin

git remote rm origin

#add new origin like Azure for me via HTTPS

git remote add origin https://[email protected]/USER/PROJECT/_git/REPONAME

#push your local repro

git push -u origin --all

#in my case put in the PAT password if you needed to generate one.

like image 2
Brandon Rose Avatar answered Oct 19 '22 16:10

Brandon Rose