代码版本控制是作为程序员,必须要考虑的问题,针对Rstudio
可以利用Github
进行版本控,下面对整个操作过程进行说明:
设定目录
在windows
系统下,选择Tools
--> Global Options
,然后选择Git/SVN
,选择Git executable
,所以安装前提是你要有先安装Git
,如下图所示

然后
Create RSA Key



打开Tools
,选择shell
,输入命令:
git config --global user.email "youremail@gmail.com
git config --global user.name "yourname"
ssh -T git@github.com
使用GitHub
上的名字

新建一个一个工程
新建一个工程,选择New Directory

然后勾选Create a git repository

这个时候Rstudio
会出现git
栏,提交到本地,只需要在git
栏下面点击commit
,即可提交至本地

可以将代码保存至GitHub
上,并且创建分支,在GitHub
上创建一个New respository
,命名为test

打开Rstudio
中的Shell
窗口,输入git
命令
git remote add origin https://github.com/chengfeifan/test.git
git config remote.origin.url git@github.com:chengfeifan/test.git
git pull origin master
git push origin master
将origin
重新定向
git remote set-url origin https://github.com/chengfeifan/test.git
在本地新建一个GitHub
上已经存在的项目
首先在Rstudio
上新建一个project
,选择version control
,然后选Clone Git Respository
,将GitHub
上repository
的url
加入到选项中

然后在shell
窗口输入
git config remote.origin.url git@github.com:ewenharrison/test.git
git中设置上游
在git
的时候,我们会建立许多有特性的分支,建立分支的时候,如何使得远端也出现分支,需要用到下面的命令:
git push --set-upstream origin master
网友评论