Windows – How to use ‘git add’ command on a file whose path includes a directory with spaces

gitgit-bashwindows

I'm trying to use Git Add command to stage a couple of files for committing later. However, I can't seem to add it because Git bash doesn't like a directory with spaces in it. How can get around this issue?

I'm using Win 7 OS. My command looks like the one below:

git add folder1/folder2/new folder/folder3/myFile.txt

The error that I'm getting is the following:
new: No such file or directory

Thanks!

Best Answer

You should be able to get around this problem if you put the path in quotes:

git add "folder1/folder2/new folder/folder3/myFile.txt"
Related Question