Git错误汇总

Git提示rejected

To github.com:zhuxiaoxi/Web-Demo.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:zhuxiaoxi/Web-Demo.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.

原因
远程仓库有一部分代码已经被包含不允许直接推送到远程仓库

解决方法

  • 在推送时,使用-f选项,强制推送
git push origin master -f

Git提示remote origin already exists

fatal: remote origin already exists.

原因
已经设置了一个远程仓库,无法设置新的

解决方法

  • 执行git remote rm origin,再修改远程仓库git remote add origin git@github.com:zhuxiaoxi/dotfiles.git

Git提示fatal: refusing to merge unrelated histories

git pull origin master
From github.com:zhuxiaoxi/dotfiles

  • branch master -> FETCH_HEAD
    fatal: refusing to merge unrelated histories

解决方法

  • 在拉取时,使用--allow-unrelated-histories选项,忽略无关的历史
git pull origin master --allow-unrelated-histories

Git提示Please make sure you have the correct access rights

ssh: Could not resolve hostname origin: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方法

# git push origin:peppa 错误,修改为下面的
git push origin :peppa
posted @ 2018-04-05 15:47  zhuxiaoxi  阅读(247)  评论(0编辑  收藏  举报