Software Developer


© 2022

Git - WSL - Visual Studio Code - fix for 'unable to write new index file'

  • Error in external git client (for example SourceTree, GitKraken):
    Rename from 'C:/path/to/repository/.git/index.lock' to 'C:/path/to/repository/.git/index' failed. 
    fatal: unable to write new index file
  • OS: Windows
  • Project opened in Visual Studio Code
  • Remote connection type: WSL
  • Visual Studio Code Extension: Remote - WSL

Here is the fix:

F1>”Open Remote Settings (WSL: Ubuntu) and add the following lines to your settings.json.

"remote.WSL.fileWatcher.polling": true,
"files.watcherExclude": {
    "**/.git/**": true