git报错之index.lock

当想回退到某个版本的时候,用git reset --hard commit_id,发现报错,原因是.git目录下多了个index.lock文件,可以通过rm命令删除,然后再回退

rm -f ./.git/index.lock //删除index.lock文件

关于commit_id 可以通过 git log命令查看提交的历史记录,如:

原文地址:https://www.cnblogs.com/toward-the-sun/p/6875626.html