Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git rm file name with space

Tags:

git

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!

like image 215
J W Avatar asked Aug 07 '12 23:08

J W


People also ask

How do I add a file to a git space?

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.

How do I rm a file in git?

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.

Does git rm actually delete the file?

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.

What is the difference between rm and git rm?

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.


1 Answers

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 TeTab

will likely complete the directory name:

$ git rm TestingService/

Then typing part of the file name and another tab:

$ git rm TestService/TeTab

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.

like image 57
Keith Thompson Avatar answered Oct 14 '22 16:10

Keith Thompson