Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 648  / 2 Years ago, thu, april 28, 2022, 1:53:06

In order to make uploading the code to github easily, I created a sh script



#commit.sh
git add .
git commit -m $1
git push origin master


But when I run it by saying ./commit.sh "comment1 comment2 comment3" , I get the error of:



error: pathspec 'comment2' did not match any file(s) known to git.
error: pathspec 'comment3' did not match any file(s) known to git.


What's wrong and how do I make it work?


More From » 12.10

 Answers
5

Always quote your variables! Change it to



git commit -m "$1"


and then



./commit.sh "comment1 comment2 comment3"


will work.


[#32272] Friday, April 29, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
inciplyies

Total Points: 10
Total Questions: 114
Total Answers: 93

Location: French Polynesia
Member since Sun, Dec 20, 2020
3 Years ago
;