---
title: "Git – fatal: Unable to create 'XXX/.git/index.lock’: File exists.的解决办法"
author: "flex_莫冲"
date: "2013-11-29T14:38:54Z"
tags: []
categories: ["行业应用"]
slug: "git-fatal-unable-to-create-xxx-git-index-lock-file-exists"
draft: false
lastmod: "2013-11-29T14:40:12Z"
id: 1982923
url: "https://lhdst-163-com.iteye.com/blog/1982923"
---

参考资料：
http://sheshui.me/articles/git-quickly-tutorial-20120517
http://stackoverflow.com/questions/9282632/git-index-lock-file-exists-when-i-try-to-commit-but-cannot-delete-the-file

我的说明：

我操作的是ubuntu环境。window远程
1 若在window下远程打开操作窗口（不是console），进入.git目录删除index.lock文件，删除后再commit会自动再次生成index.lock。无法提交。
2 使用putty console下操作，进入.git目录执行 rm -f index.lock 删除index.lock 虽然能删除，但是也是每次都会再生成。无法提交
3 在.git同级目录，执行rm -f .git/index.lock （或者rm -f git/index.lock） 删除后可提交。成功！

