版权声明:转载请注明出处 https://blog.csdn.net/u013837825/article/details/88608203
github 使用笔记
1.申请github账号
2.添加SSH Key
- 本地生成
SSH Key秘钥对
ssh-keygen -t rsa -C "[email protected]"
- 将
公钥文件id_rsa.pub
里的内容添加到github SSH keys
cat ~/.ssh/id_rsa.pub
将内容复制进https://github.com/settings/ssh/new
的Key
内容里
- 测试
ssh -T [email protected]
出现一下内容,表示连接成功:
Hi {your github name}! You’ve successfully authenticated
3.在github上添加仓库
-
创建仓库
-
复制仓库地址
本次测试地址:[email protected]:morningcat2018/github-demo.git
4.git本地仓库
连接远程github仓库
mkdir github-demo
cd github-demo
# 初始化仓库
git init
# 提交
touch git.txt
git add git.txt
git commit -m 'add git.txt'
# 添加远程仓库
git remote add origin [email protected]:morningcat2018/github-demo.git
# 拉取
git pull origin master --allow-unrelated-histories
git fetch
git pull origin master
# 推送
git push -u origin master
此时本地的git记录已推送到远程github仓库了
参考文档
- 遇到问题
fatal: 拒绝合并无关的历史
问题详情:
git pull origin master
来自 github.com:morningcat2018/spring-bpp-demo
* branch master -> FETCH_HEAD
fatal: 拒绝合并无关的历史
解决方案:
https://blog.csdn.net/lddtime/article/details/77817317