一, 问题
我们在使用 Git 指令的时候往往会出现如下错误.
- $ Git push -u origin master
- To https://github.com/pzq7025/ss-fly.git
- ! [rejected] master -> master (fetch first)
- error: failed to push some refs to 'https://github.com/pzq7025/ss-fly.git'
- hint: Updates were rejected because the remote contains work that you do
- hint: not have locally. This is usually caused by another repository pushing
- hint: to the same ref. You may want to first integrate the remote changes
- hint: (e.g., 'git pull ...') before pushing again.
- hint: See the 'Note about fast-forwards' in 'git push --help' for details.
二, 解决
首先分析这个错误是因为当前目录下. Git 文件中没有 README.md 的文件, 因此需要用指令 [Git pull --rebase origin master] 先拉取 GitHub 中的文件, 在用 [Git push origin master] 完成上传, 除此之外指令 [Git push -u origin master] 可以将空项目完成上传.
三, 结果
这样就完成了本地到 GitHub 的内容上传
四, 总结
Git 在刚开始使用的时候会遇到很多问题, 但是基本的思想就是:
1. 用指令 [SSH-keygen -t rsa -C "注册邮箱"] 建立秘钥
2. 将秘钥和 GitHub 连接
3. 创建本地 Git[Git init]
4. 获取连接对象 [Git remote add origin [Git 的 https 位置]]
5. 完成 Git 上传 [Git push origin master]
来源: http://www.bubuko.com/infodetail-3092928.html