gitvisual-studio-codegit-addgit-stage

How to stage the files to the local git repository where file names has space in them?


I have 2 files locally: File 1.txt and File 2.txt.

When I stage the files with the command git add File 2.txt, it is giving me the below error:

fatal: pathspec 'File' did not match any files

git stage file error


Solution

  • I solved myself by referring the article in Noble desktop Blog.

    The answer is:

    If the file name/path has a space, wrap it in quotes(Single/double).

    Command:

    git add 'File 2.txt'