I am relatively new to Linux so this is probably an easy one but when I use quotes (single or double) around my git commit messages the words are taken as filenames. How do I use -m with spaces in the message - I do not want to use vi.
user@linux:~/Documents/tmp$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: afile
user@linux:~/Documents/tmp$ git commit -m ¨this message has spaces and fails¨
error: pathspec 'message' did not match any file(s) known to git.
error: pathspec 'has' did not match any file(s) known to git.
error: pathspec 'spaces' did not match any file(s) known to git.
error: pathspec 'and' did not match any file(s) known to git.
error: pathspec 'fails¨' did not match any file(s) known to git.
user@linux:~/Documents/tmp$ git commit -m ¨nospacesisokay¨
[master (root-commit) 37afcd6] ¨nospacesisokay¨
1 file changed, 1 insertion(+)
create mode 100644 afile
Use regular quotes (double quotes ", or quotes '), fellow :) ¨ is too exotic for bash so it splits down your message into tokens by whitespaces and pass these tokens separately to git.
In unix-like systems, unlike MS Windows cmd.exe, (well, MinGW and Cygwin are unix-like too :) ) splitting command line into tokens is peformed by a shell, be it a sh- or csh-compatible shell (bash, zsh, ash, sash, ksh, tcsh and so on and so forth). A program receives a ready to use array of arguments. So if a user wants to pass a line with spaces, escape-sequences and so on, she should quote or escape that line properly.
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