fatal: Unable to create '.../.git/index.lock': File exists. means Git found a lock file left in the repository and refuses to touch the index. If no other Git process is running, the lock is stale: delete .git/index.lock and run your command again.

Check first, delete second. Close any editor that is waiting on a commit message, look for a running git process, and only when there is none remove the file. Deleting a stale lock loses no commits; at worst it holds a half-written copy of the index.

The error

PS> git add notes.txt
fatal: Unable to create 'C:/.../a1/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

The long absolute path was shortened; nothing else changed. A git commit -am in the same repository failed with the identical message.

Why it happens

Every command that writes the index (add, commit, checkout, merge, stash) first creates .git/index.lock, writes the new index into it and renames it over .git/index when it is done. The file is how two Git processes avoid writing the index at the same time, so a second command that finds it stops at once.

Usually the lock is genuine: a git commit is still waiting in an editor, or an IDE is running a background git status. When a Git process is killed halfway (a closed terminal, a crashed IDE, a power cut), the rename never happens and the lock stays behind with no owner. Git cannot tell the two cases apart, which is why the message asks you to check.

The fix

First make sure nothing is running. In PowerShell:

PS> Get-Process git -ErrorAction SilentlyContinue
PS> Get-Item .git\index.lock

Mode   LastWriteTime       Length Name
----   -------------       ------ ----
-a---- 06-11-2026 12:44:30      0 index.lock

No git process was listed, and the lock was the empty file made for the test. With that confirmed, remove it and repeat the command (Git Bash shown):

$ rm .git/index.lock
$ git commit -am second
[main b1c78a0] second
 1 file changed, 1 insertion(+), 1 deletion(-)

If a git process does show up, let it finish or close the program that owns it (an editor tab waiting for a commit message is the usual one) and the lock disappears on its own. Deleting a lock that a live process still holds can leave a half-written index, so do not skip the check. If the error comes back every few seconds, an IDE or a sync tool is running Git in the background; pause it while you work in the terminal.

How it was reproduced

A throwaway repository with one commit, on Git for Windows 2.45.2 under Windows 11 and Windows PowerShell 5.1. An empty .git\index.lock was created to stand in for a crashed Git process; git add and git commit -am then both failed with exit code 128. Get-Process git returned nothing, the file was removed with rm in Git Bash, and the same commit succeeded.

Frequently asked

Is it safe to delete .git/index.lock?
Yes, when no Git process is running in that repository. Deleting a stale lock loses no commits; at worst it holds a half-written copy of the index. Check for a running git process or an editor waiting on a commit message first.
Why does git keep saying index.lock file exists?
Something keeps starting Git in the background, usually an IDE, a Git GUI or a file sync tool. Close or pause it, or the lock reappears each time it runs a status check.
Where is the index.lock file?
In the .git folder at the root of the repository, next to the index file. The error message prints its full path.

More decoded errors in the Fixes category. If Git cannot find a repository at all, see fatal: not a git repository.