legoniko
legoniko

Reputation: 95

Cannot do git checkout because of file errors and unable to git stash

I am trying to do a git checkout of a branch:

$ git checkout remotes/origin/QuestionFormJN
error: Your local changes to the following files would be overwritten by 
checkout:
    ICompute-api/.vs/ICompute-api/v15/Server/sqlite3/storage.ide-shm
    ICompute-api/.vs/ICompute-api/v15/Server/sqlite3/storage.ide-wal
Please commit your changes or stash them before you switch branches.
Aborting

Then I try to do a git stash and get this error:

$ git stash
Saved working directory and index state WIP on master: e52c54c fixed login
Unlink of file 'ICompute-api/.vs/ICompute- 
api/v15/Server/sqlite3/storage.ide-shm' failed. Should I try again? (y/n) y
Unlink of file 'ICompute-api/.vs/ICompute- 
api/v15/Server/sqlite3/storage.ide-shm' failed. Should I try again? (y/n) n
error: unable to unlink old 'ICompute-api/.vs/ICompute- 
api/v15/Server/sqlite3/storage.ide-shm': Invalid argument
Unlink of file 'ICompute-api/.vs/ICompute- 
api/v15/Server/sqlite3/storage.ide-wal' failed. Should I try again? (y/n) n
error: unable to unlink old 'ICompute-api/.vs/ICompute- 
api/v15/Server/sqlite3/storage.ide-wal': Invalid argument
fatal: Could not reset index file to revision 'HEAD'.

What am I doing wrong?

Upvotes: 2

Views: 3257

Answers (2)

Abhijit Mondal Abhi
Abhijit Mondal Abhi

Reputation: 1899

I was using Windows 10 and faced this same issue. After closing Visual Studio, it works fine.

Upvotes: 1

bk2204
bk2204

Reputation: 76884

The error "Unlink of file failed" (which is almost always seen only on Windows) means that the file couldn't be removed when stashing, usually because it's in use by some other program. On Windows, it usually isn't allowed to delete a file in use by another program, so you'd need to figure out whatever it is and close it. You could also restart your computer, and see if that fixes the problem running git stash.

On a Unix system, this error would indicate that you used a Git compiled for a newer version of your OS on a very, very old version.

Upvotes: 4

Related Questions