转载:Ubuntu 18.04 上传项目到Github
程序员文章站
2022-03-07 12:52:06
...
1.本地创建 SSH Keys
GitHub支持多种加密算法,选取rsa,创建好的加密文件在~/.ssh下。
ssh-****** -t rsa -C "aaa@qq.com"
- 1
oectDetection$ ssh-****** -t rsa -C "aaa@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/yuyang/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/yuyang/.ssh/id_rsa.
Your public key has been saved in /home/yuyang/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Qhm9b/J8A9pW+53GHbtpY6/WH4DfQCgQ6KEjS8L3iEE aaa@qq.com.net
The key's randomart image is:
+---[RSA 2048]----+
| o+. |
| E o oo . |
|o o + o . . |
|.= + o . . o |
|o * + . S. . o |
| o . . .. + o +. |
| B o o.++|
| . = + .O*|
| . . +*=O|
+----[SHA256]-----+
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
2 到GitHub上创建SSH keys
- cd到~/.ssh下打开id_rsa.pub,复制加密的内容:
(base) aaa@qq.com:~/.ssh$ more id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpK0JmXAHA6lZQbGIudKM7YmFsieaARjG5cguq1zn
tUhomdkOPeqopcwGNuTd/YPyUkqaFNQcPhQNv8ucpDR17EsVGVj8PFxSI8bTWaehRUL/I67hwlQEzYe
d15Xn1Pem2QFuCP55ZwTy0jH83y4lcgtHesHkFf7SqGG8Gpp6iJqnxOuLBg0IOEud/Nehh8XuD6eE8R
8BpOhG0C93rmku/c0pUpcW6MEQVSCL9dsxRrQjDSTrV3on32v+ZOB8V5m3tuBpqSQhn2HuPBnwwpQto
Sadhq7ELL+n/+dsGtAH1tbeydT3ADtOA2Kxnmxng/jUVCsnYA8DR3DYOwiggsLZB aaa@qq.com.
net
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 到GitHub上创建SSH keys,点击”New SSH Key”:
- 点击Add SSH key
- 验证 SSH Keys 是否添加成功,如下所示,成功。
(base) aaa@qq.com:~$ ssh -T aaa@qq.com.com
Hi yy2536298120! You've successfully authenticated, but GitHub does not provide shell access.
- 1
- 2
- 进行全局配置
输入Github上的用户名和邮箱地址
git config --global user.name 'oceanshadow'
git config --global user.email 'aaa@qq.com'
- 1
- 2
3 往GitHub现有仓库中提交代码
- 初次提交
#新建一个REDEMA.md文件,可以在里面编写文档
echo "# exmple" >> REDEMA.md
#新建并初始化仓库
git init
#将文件夹内的所有文件都添加到仓库中,如果缺少哪个,可以使用 git add XXXX 添加;
git add .
#上传文件至本地仓库, -m之后的输入是本次提交的说明。
git commit -m "first commite"
#将本地文件夹和github仓库关联,后面是你自己的github仓库地址
git remote add origin aaa@qq.com:yy2536298120/MXNet-Demo.git
git pull origin master
#输入用户名和密码,输入正确,就可以成功将README.md上传到github上。
git push -u origin master
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 提交更改
#更新代码至最新
git pull
#查看状态
git status
#将所有变动文件提交到暂存区
git add .
#将变动文件提交至本地仓库,说明为“会把工作时的所有变化提交到暂存区”
git commit -m "init project"
#连接远程GitHub仓库项目
git remote add origin aaa@qq.com.com:yy2536298120/MXNet-Demo.git
#将本地仓库项目更新提交到GitHub仓库项目中
git push -u origin master
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
上一篇: Github fork sources