git中常见的错误

说明

Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理。在推出后,Git在其它项目中也取得了很大成功,尤其是在Ruby社区中。目前,包括Rubinius、Merb和Bitcoin在内的很多知名项目都使用了Git。Git同样可以被诸如Capistrano和Vlad the Deployer这样的部署工具所使用。[来自某度]

此文章会持续更新,总结自己使用git遇到的错误以及解决办法。

git开发错误总结

cannot lock ref

错误描述

error: cannot lock ref ‘refs/remotes/origin/dev’: ref refs/remotes/origin/dev is at 19070aed6873f8d58f35e4631272b59f13927a1c but expected 8a5b3bda0778070bd6b92123556475c9484e04b8
From 120.26.77.241:yourWorkspace/yourProject

如果使用的sourceTree可视化工具,看到的完整的信息是这样的:
git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree fetch origin
error: cannot lock ref ‘refs/remotes/origin/dev’: ref refs/remotes/origin/dev is at 19070aed6873f8d58f35e4631272b59f13927a1c but expected 8a5b3bda0778070bd6b92123556475c9484e04b8
From 120.26.77.241:dongjia/php
! 8a5b3bd..007af81 dev -> origin/dev (unable to update local ref)
Completed with errors, see above

解决办法

进入到项目根目录,执行下面命令:

rm .git/refs/remotes/origin/dev

git fetch

如果没有权限,请加sudo,windows用户在文件工具开启查看隐藏文件,进入到对应目录删除该文件即可。

    原文作者:Joyven
    原文地址: https://segmentfault.com/a/1190000005346163
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞