问题
Q1 上行代码:无法推送
- cmd
git push -u origin master
- Describe
error: src refspec master does not match any.
error: 无法推送一些引用到 'origin'
- Reason
本地文件为空,未添加上传文件 - Plan
git add *
git commit -m 'update project'
Q2 上行代码:hostname或服务未识别
- cmd
git push -u origin master
- Describe
ssh: Could not resolve hostname github: Name or service not known
fatal: 无法读取远程仓库。
- Reason
未拉取线上文件至本地 - Plan
git pull origin master
Q3 上行代码:添加永久IP地址
- cmd
git push -u origin master
- Describe
Warning: Permanently added the RSA host key for IP address 'xx.xx.xxx.xxx' to the list of known hosts.
To git@github.com:hahaha/ftpmanage.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:hahahah/ftpmanage.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.
- Reason
未拉取线上文件至本地 - Plan
git pull --rebase origin master
Q4 上行代码:拒绝合并
- cmd
git pull origin master
- Describe
fatal: 拒绝合并无关的历史
- cmd
git push -u origin master
- Describe
提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。
- Plan
# 远程仓库与本地关联
git branch --set-upstream-to=origin/master master
# 修改信息
# 请输入一个提交信息以解释此合并的必要性,尤其是将一个更新后的上游分支
# 合并到主题分支。
#以 '#' 开头的行将被忽略,而且空提交说明将会终止提交。
# 填写必要信息
# 保存
ctl+x
# 远程仓库同步到本地
git pull --allow-unreleated-histories
Q5 上行代码:重复提交
- cmd
git commit -m 'NNTest'
- Describe
位于分支 master
尚未暂存以备提交的变更:
删除: NNTest.py
删除: images/loss.png
删除: images/results.png
修改尚未加入提交
- Reason
使用git add后,变更了文件数量,缓冲区已经存在文件了,所以在此提交前需要处理缓冲区文件。 - Solve
查看工作区状态
git status
位于分支 master
您的分支领先 'origin/master' 共 2 个提交。
(使用 "git push" 来发布您的本地提交)
尚未暂存以备提交的变更:
(使用 "git add/rm <文件>..." 更新要提交的内容)
(使用 "git checkout -- <文件>..." 丢弃工作区的改动)
删除: VGGNet/cifa10_data/cifar-10-batches-bin/batches.meta.txt
删除: VGGNet/cifa10_data/cifar-10-batches-bin/data_batch_1.bin
删除: VGGNet/cifa10_data/cifar-10-batches-bin/data_batch_2.bin
删除: VGGNet/cifa10_data/cifar-10-batches-bin/data_batch_3.bin
删除: VGGNet/cifa10_data/cifar-10-batches-bin/data_batch_4.bin
删除: VGGNet/cifa10_data/cifar-10-batches-bin/data_batch_5.bin
删除: VGGNet/cifa10_data/cifar-10-batches-bin/readme.html
删除: VGGNet/cifa10_data/cifar-10-batches-bin/test_batch.bin
删除: VGGNet/cifa10_data/cifar-10-binary.tar.gz
删除:git checkout – <文件名>
git checkout -- VGGNet/cifa10_data
位于分支 master
您的分支领先 'origin/master' 共 2 个提交。
(使用 "git push" 来发布您的本地提交)
无文件要提交,干净的工作区
Q6 上行代码:git@https协议处理报错
- cmd
git push -u origin master
- Describe
fatal: I don't handle protocol 'git@https'
- Reason
控制台有其他上行或下载进程; - Plan
关闭控制台的其他联网集成或换另一台主机;
Q7 上行代码:仓库源未出现
- cmd
git push -u origin master
- Describe
fatal: 'origin' does not appear to be a git repository
fatal: 无法读取远程仓库。
- Reson
远程仓库为添加源. - Plan
git remote add origin https://github.com/xindaqi/AIFuture.git
Q8 上行代码:跟踪文件为空
- cmd
git commit -m 'update'
- Describe
位于分支 master
未跟踪的文件:
images/
models/
提交为空,但是存在尚未跟踪的文件
- Reason
git commit后,提交代码时,未提交成功,继续git push出现. - Plan
git pull --rebase origin master
Q9 连接仓库失败
- cmd1
git -T git@github.com
- Result1
git@github.com: Permission denied (publickey).
- cmd2
sudo git -T git@github.com
- Result2
The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
- 原因
未配置SSH秘钥 - 解决
将本地秘钥上传github
cd ~/.ssh
vim id_rsa.pub
# 复制内容,打开github,并登陆
github配置如下
setting
↦
\mapsto
↦ SSH and GPG keys
↦
\mapsto
↦ New SSH Key
Q10 pull出错
- cmd
git pull origin master
- Reuslt
ssh: Could not resolve hostname github: Name or service not known
fatal: 无法读取远程仓库。
请确认您有正确的访问权限并且仓库存在。
- 原因
未在本地添加远程仓库的源 - 解决
将远程的源添加到本地
git remote add origin https://github.com/xindaqi/AIWeb.git
[参考文献]
[1]https://www.cnblogs.com/zhenglinfei/p/7396758.html
[2]https://www.cnblogs.com/jeremylee/p/5715289.html
[3]https://blog.youkuaiyun.com/yamanda/article/details/79375698
[4]https://blog.youkuaiyun.com/dream_follower/article/details/53907217