一、github配置SSH key
1.设置git的用户名与邮箱
请自行替换相应的字段
git config --global user.name "python-faker"
git config --global user.email "578946900@qq.com"
git config --list 可查看当前Git环境所有配置类型
2.检查ssh key 是否存在
cd ~/.ssh
ls
看是否存在 id_rsa 和 id_rsa.pub文件,如果存在,说明已经有SSH Key
如下可以看到 是没有的

3.产生ssh key
请自行替换相应字段
ssh-keygen -t rsa -C "578946900@qq.com"
一直按回车按成自动配置。

关于上述命令的解释
When you create the ssh you type (for example):
ssh-keygen -t rsa -C “any comment can be here”
当你创建ssh的时候
-t = The type of the key to generate
密钥的类型https://www.bootcss.com/p/git-guide/
-C = comment to identify the key
用于识别这个密钥的注释
So the Comment is for you only and you can put anything inside.
Many sites and software are using this comment as the key name.
所以这个注释你可以输入任何内容,很多网站和软件用这个注释作为密钥的名字
4.检查ssh key是否存在
cd ~/.ssh
ls
如图

5.获取ssh key
cat id_rsa.pub
//拷贝秘钥 ssh-rsa开头,全部复制 包括ssh-rsa

6.github添加ssh key
点击github头像选择setting

选择 ssh and gpg keys 点击new ssh key

取一个名字,把之前cat 的到的ssh key 复制进去

完成添加。
7.验证
测试是否成功配置
ssh -T git@github.com
//出现下面语句即为成功
Hi python-faker! You've successfully authenticated, but GitHub does not provide shell access.
二、将本地项目上传至仓库
比如我想将/home/cheng/git/auto_label整个文件夹下的所有内容上传至仓库
1.在github新建仓库
登录github
左上角+ 号 new repository

输入一个名字,比如我的csdn_example

可以看到如下ssh地址

2.本地项目配置
//进入文件夹
cd /home/cheng/git/auto_label
//初始化
git init
//添加需要追踪的文件 .表示全部添加
git add .
//commit 本地提交添加
git commit -m ’注释信息,可以写第一次提交等等‘
3.推送只github仓库
请自行替换仓库地址,这里可以填2.1中创建新的仓库的ssh地址。
//添加要修改的仓库地址
git remote add origin git@github.com:python-faker/auto-label-for-yolov5.git
//push 上传指令
git push -u origin master

ok,本地代码已经推送到github了。
4.补充
嫌麻烦的话直接在网页操作就可以,直接上传
1.Github上Fork别人代码后,提交自己的修改
2.git使用简易指南
3291




被折叠的 条评论
为什么被折叠?



