Liraj Maharjan
Liraj Maharjan

Reputation: 11

Git adding file having space in name

I am trying to update my file, but I was unable to do so because of file name contains two words

$ git add 00162808_LirajMaharjan_CP_Design/Class diagram.mdj

Error:

fatal: pathspec '00162808_LirajMaharjan_CP_Design/Class' did not match any files

Can I add a file like 'Class diagram/mdj' with spaces in the name?

Upvotes: 0

Views: 7152

Answers (2)

1615903
1615903

Reputation: 34732

Either escape the space with a backslash:

git add 00162808_LirajMaharjan_CP_Design/Class\ diagram.mdj

Or quote the filename:

git add "00162808_LirajMaharjan_CP_Design/Class diagram.mdj"

Single quotes work too:

git add '00162808_LirajMaharjan_CP_Design/Class diagram.mdj'

Upvotes: 7

Nur Zico
Nur Zico

Reputation: 2447

Try git add 00162808_LirajMaharjan_CP_Design/Class\ diagram.mdj

Upvotes: 1

Related Questions