发布于 

Git出现的错误

可能出现的错误:

1git push 出现Everything up-to-date 解决方法

1.可能你没有git.addgit commit

1
git add .
1
git commit -m 'message'
1
git push origin master

2.无法推送远程仓库

​ error:src refspec master does not match any ||| error:failed to push some refs to ‘仓库地址’

​ 暂存区没有文件

​ 解决:

1
2
git add .
git commit -m "xxxx" // xxx随意

3.显示没有权限

​ 可以添加公钥:

1
2
# 第一步
ssh-keygen -t rsa -C 'youremail'
  1. 然后一路Enter(回车)

  2. 系统盘—>用户—>你的文件—>.ssh文件夹里 —>id_rsa.pub(这是公共秘钥)

注:切记!!!切记!!!切记!!!里面的id_rsa是私人秘钥不能给其它人看
  1. 打开github—>点击你的头像settings—>然后在点击SSH and GPG keys—>点击Add deploy key新建一个ssh—>Title随便写—>Key里把id_rsa.pub里面的信息复制进去【注:是公共秘钥不要复制错误】

在git bash中输入:

1
ssh -T git@github.com

显示你的用户名就成功了

4.推送远程仓库出现的问题

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.

问题原因:

其他地方向同一远端库推送了代码,导致本地不是最新的

解决方案:

先从远端pull一下,执行:

1
git pull

5.git推送更新出现错误

! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://github.com/xxx/xxx.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.

解决办法:

​ 如果本地代码无误后进行推送进行强制推送:

1
git push -f origin master


对了不要直接执行上面的命令,别忘了初始化以及add和commotion -m (~ ̄▽ ̄)~

待更新中…


本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。