I tried merging with the command line for a project in Xcode and I think a file needs to be removed. It is a file that exists in the branch I was merging from, but not the branch I was merging into. The problem is it has a space in the name:
TestService/TestService copy-Info.plist
How do I remove that file? thanks!
Surround the folder or file with a space in it with quotes! On Mac and Linux, you can add single quotes, but on Windows you'll have to use double quotes. …and everything worked as expected! This works for all the git commands: so add and diff , for instance, are included.
The easiest way to delete a file in your Git repository is to execute the “git rm” command and to specify the file to be deleted. Note that by using the “git rm” command, the file will also be deleted from the filesystem.
By default, the git rm command deletes files both from the Git repository as well as the filesystem. Using the --cached flag, the actual file on disk will not be deleted.
Git rm vs rmThe git rm command removes the file from both the git repository and the local file system. The rm command, on the other hand, only removes the file from the file system.
The same way you'd use rm
to remove such a file: quote the name:
git rm "TestService/TestService copy-Info.plist"
or
git rm 'TestService/TestService copy-Info.plist'
or
git rm TestService/TestService\ copy-Info.plist
Depending on your shell and the names of other files, tab completion may help with this. Typing
$ git rm Te
Tab
will likely complete the directory name:
$ git rm TestingService/
Then typing part of the file name and another tab:
$ git rm TestService/Te
Tab
will complete the filename, including an inserted \
to escape the space character:
$ git rm TestService/TestService\ copy-Info.plist
But tab completion usually only expands a unique prefix based on all the files available, so this may or may not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With