Mr.Alright---上传代码到github详细步骤

怎样使用git上传文件到github?

1.在github上创建一个新的库

Mr.Alright---上传代码到github详细步骤_第1张图片

2.添加本地的id_rsa.pub到github

如果没有的话需要生成一下,命令是

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

之后添加到下面这个地方
Mr.Alright---上传代码到github详细步骤_第2张图片

3.将代码库clone到本地

使用git clone + repo,后面的地址可以是两种形式,地址在这个地方获取
Mr.Alright---上传代码到github详细步骤_第3张图片

  1. ssh的方式,这种方式,后面提交代码的话,不需要每次都输入密码,但是如果你的公司IT限制的话可能会有问题拉不下来代码,错误信息如下
$ git clone [email protected]:xxx/test.git
Cloning into 'test'...
kex_exchange_identification: read: Connection reset by peer
Connection reset by 52.74.223.119 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

  1. https的方式,这种方式一般限制,但是提交代码的时候,每次都要输入密码,就很烦人

具体的可看下图片
Mr.Alright---上传代码到github详细步骤_第4张图片

4.添加,修改,提交

// 第一次需要 git remote add origin 一下
git remote add origin https://github.com/xxx/test.git
git branch -M main
git push -u origin main

你可能感兴趣的:(版本控制,git,github)