Git error: unlink of file failed.Should I try again?

Error

occurs when git switches branches

Unlink of file ‘XXX’ failed.Should I try again?

at first thought that something had forgotten commit, but after this error occurred several times, it became clear that it wasn’t easy.

the reason is that you have some files in your working directory that are being used by a program, which is probably Idea,VS or eclipse, but it could also be another program

The

solution is not simply to choose y or n, but to close the IDE and let the IDE release the files.

can also be used in conjunction with Process Explorer on Windows to query which programs are using the file.

https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer

if you switch back to the original branch, use git status to check for uncommitted files, then you can use

git checkout -- *

the above command restores all these corrupted files to the last commit.

Read More: