最新github仓库项目部署上传教程

秋知德雨个人 2022-3-2 1,213 3/2

1.首先下载:GIT

2.在自己任意一个盘创建一个文件夹,比如这样:

最新github仓库项目部署上传教程

 

3、安装完成后鼠标右击和者开始->程序会出现,打开Git Bash,进入bash界面。

4.创建SSH Key;

在Git Bash中输入[qzdypre]ssh-keygen -t rsa -C "你的邮箱"[/qzdypre]

最新github仓库项目部署上传教程

然后就会显示这两行:
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/16627/.ssh/id_rsa):

这是让你输入一个文件名,用于保存刚才生成的 SSH key 代码。为了避免麻烦,不用输入,直接回车,那么就会默认生成id_rsa和id_rsa.pub两个秘钥文件。
这时候已经创建好.ssh这个文件夹了,会提示:
Created directory ‘/c/Users/16627/.ssh’.

最新github仓库项目部署上传教程
紧接着又会问你:
Enter passphrase (empty for no passphrase):
就是让你输入密码,如果你设置了密码,那在你使用ssh传输文件的时候,你就要输入这个密码。为了避免麻烦,建议不用设置,直接回车。
Enter same passphrase again:
这就是让你再输入一次密码,就跟我们注册账号时候设置密码需要设置两次一样。上一步没设置密码,这里直接回车就可以了。到这里你的秘钥就设置好了,你会收到这段代码提示:
Your identification has been saved in /c/Users/…/.ssh/id_rsa
Your public key has been saved in /c/Users/…/.ssh/id_rsa.pub
还会向你展示你的秘钥长啥样

最新github仓库项目部署上传教程

当你看到上面这段代码,那就说明你的 SSH key 已经创建成功,你可以再使用[qzdypre]~/.ssh[/qzdypre]看一下,现在文件是真的存在了

最新github仓库项目部署上传教程

5.添加SSH Key到GitHub

最新github仓库项目部署上传教程

最新github仓库项目部署上传教程

(黄色框框是我已经建立的SSH key。)
点击右上角新建一个SSH Key。

title随便给他起个名字就好。然后是key,这时候你要打开你刚才在电脑上的SSH key。
还记得这一步吗:

最新github仓库项目部署上传教程

按照红框框里的路径,找到.ssh文件夹。用记事本打开id_rsa.pub文件,全选其中的内容粘贴到网页的Key中。

最新github仓库项目部署上传教程

然后你就会受到建立成功的邮件了。

最新github仓库项目部署上传教程

6.测试一下该SSH key

在git Bash 中输入以下代码
$ ssh -T git@github.com
注意是git@github.com,不是你的邮箱。

然后会提示你:
The authenticity of host ‘github.com (13.229.188.59)’ can’t be established.
RSA key fingerprint is SHA256:nThbg6kXUp…
Are you sure you want to continue connecting (yes/no/[fingerprint])?

输入yes,回车

最新github仓库项目部署上传教程

接下来就会提示你输入密码,如果上边设置ssh的时候,你没设置密码会提示你:
Warning: Permanently added ‘github.com,192.30.255.112’ (RSA) to the list of known hosts.
警告完了,如果你能看到如下提示,那你已经成功设置SSH密钥。
Hi “用户名”! You’ve successfully authenticated, but GitHub does not provide shell access.
如果你看到 access denied,者表示拒绝访问,那么你就需要使用 https 去访问。

7、初始化本地git仓库配置

$ git init

8、添加远程仓库

$ git remote add origin http://192.168.1.183/git/pspb.git

9、将项目文件添加到本地暂存区

$ git add .

10、添加暂存区文件到Git本地仓库

git commit -m "<提交描述>"

11、将远程仓库拉取pull下来

git pull origin main

12、将文件push到远程仓库

git push -u origin main

13、如果出现:

On branch main
nothing to commit, working tree clean

就删除本地分支,重新拉取试试
[qzdypre]
git branch -b test
git branch -D master
git fetch origin master
git chekcout master
git add .
git push origin master

[/qzdypre]
14、接下来就会弹出

最新github仓库项目部署上传教程

让把你登陆授权,之后就上传了

15、如果你发现仓库main仓库没有项目,但是main下面的master 有项目奖执行下面的:

统一远程和本地的仓库名称即可

把本地的 master 仓库名称修改为远端的 main

重命名命令: git branch -m master main

然后继续提交:git push origin main

16、如果提示

最新github仓库项目部署上传教程

执行git pull --rebase origin master

14.更新项目

git pull 下载GitHub上的代码并合并,防止提交新代码的时候冲突报错git add 将代码添加到仓库git commit -m "xxx" 提交代码到仓库git push 提交到GitHub

- THE END -
Tag:

秋知德雨个人

3月04日15:59

最后修改:2022年3月4日
6

非特殊说明,本博所有文章均为博主原创。

共有 0 条评论