git error list
这里列举一些常见的git错误,以供遇到相同错误时有个参考.
git push内容冲突
Q:报错内容如下:
bash
[echoxu@echoxu-linux dist]$ git push origin -u master
To blog.echoxu.cn:/home/git/www/www.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@blog.echoxu.cn:/home/git/www/www.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.
A:解决方法如下:
git pull
git branch --set-upstream-to=origin/master master
git pull origin master --allow-unrelated-histories
git push -u origin master
gc.log 错误
- 问题描述:
使用git push时报错如下:
bash
remote: error: The last gc run reported the following. Please correct the root cause
remote: and remove gc.log.
remote: Automatic cleanup will not be performed until the file is removed.
remote:
remote: warning: There are too many unreachable loose objects; run 'git prune' to remove them.
- 解决办法:
登录git服务器,进入到项目的git路径,删除gc.log文件并运行git prune即可 cd /home/git/docV1/docV1.git
rm -rf gc.log
git prune
远程 origin 已经存在
解决办法:
git remote remove origin 删除远程仓库
git remote -v 查看当前添加的远程仓库
git-receive-pack: 未找到命令
bash
git push
bash: git-receive-pack: 未找到命令
fatal: 无法读取远程仓库。
请确认您有正确的访问权限并且仓库存在
解决办法:
sudo ln -s /usr/local/git/bin/git-receive-pack /usr/bin/git-receive-pack
- git-upload-pack: 未找到命令
bash
正克隆到 'blog'...
bash: git-upload-pack: 未找到命令
fatal: 无法读取远程仓库。
请确认您有正确的访问权限并且仓库存在。
解决办法:
sudo ln -s /usr/local/git/bin/git-upload-pack /usr/bin/git-upload-pack