When I want to add something to the staging area I normally type git add < folder-name >. However, I can't add folders with spaces in the name. My git add
auto complete doesn't correctly escape the spaces.
I have a folder named: Folder A
I run the command git add F < tab-autocomplete >
which becomes git add Folder A/
.
If I try and add this folder it will throw an error:
fatal: pathspec 'Folder' did not match any files
This is because the correct syntax should be git add Folder\ A/
.
I'm not sure how to fix this though and I can't find any resources with a permanent fix. This issue "How git deals with folder names with spaces" describes a fix. But it involves putting speech marks around the folder name which I don't really want to do. Is there a better solution?
I'm using git version 2.2.0 and zsh version 5.0.7. Thank you in advance!
The solution is to wrap the folder name inside ' and ' (single quotes).
In your example, try the following:
git add 'Folder A'
I hope this helps :)