Skip to content

Latest commit

 

History

History
107 lines (60 loc) · 3.35 KB

git教程.md

File metadata and controls

107 lines (60 loc) · 3.35 KB

代码版本控制是作为程序员,必须要考虑的问题,针对Rstudio可以利用Github进行版本控,下面对整个操作过程进行说明:

设定目录

windows系统下,选择Tools --> Global Options,然后选择Git/SVN,选择Git executable,所以安装前提是你要有先安装Git,如下图所示

image-20210329122736942

选择git目录

然后Create RSA Key

image-20210329122752182

image-20210329122816918

image-20210329122840750

打开Tools,选择shell,输入命令: git config --global user.email "[email protected] git config --global user.name "yourname" ssh -T [email protected] 使用GitHub上的名字

image-20210329122854117GitHub连接

新建一个一个工程

新建一个工程,选择New Directory

image-20210329122906337

新建工程

然后勾选Create a git repository

image-20210329122936787

创建Git

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

image-20210329122958635GitHub提交

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

image-20210329123014956

GitHUb上创建

打开Rstudio中的Shell窗口,输入git命令

git remote rm origin
git remote add origin  https://github.com/cystone/advancedSingleCell.git
git config remote.origin.url git@github.com:cystone/advancedSingleCell.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,将GitHubrepositoryurl加入到选项中

image-20210329123033548

Paste_Image.png

然后在shell窗口输入 git config remote.origin.url [email protected]:ewenharrison/test.git

git中设置上游

git的时候,我们会建立许多有特性的分支,建立分支的时候,如何使得远端也出现分支,需要用到下面的命令:

 git push --set-upstream origin master

常见错误和解决办法

$git push fatal: unable to access 'https://github.com/cystone/advancedSingleCell.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

git config --global --unset http.proxy
git config --global http.sslVerify false

如果有如下: Enter passphrase for key '~/.ssh/id_rsa':

ssh-add ~/.ssh/id_rsa