On Wed, 24 Apr 2013 11:11:17 -0700 (PDT)
Andrzej Borucki <
borucki...@gmail.com> wrote:
> If I type:
> git commit -a -m 'initial commit'
> instead of
> git commit -a -m "initial commit"'
> will be warning:
> fatal: Paths with -a does not make sense.
> whereas in Linux shell is probably acceptable single quote.
My take on this follows.
There are two facts:
1) POSIX shells (those found on Unix systems, Linux- or *BSD-based
systems, and on Mac OS) perform the so-called "argument expansion"
before calling the user-supplied command.
They also support quoting of arguments using both single quotes
and double quotes (these types of quoting have different semantics
but this is irrelevant to the issue in hand).
This means when you run
git commit -a -m 'Initial commit'
or
git commit -a -m "Initial commit"
in a POSIX shell, the program named "git" will be run with *four*
*distinct* arguments: "commit", "-a", "-m" and "Initial commit",
without the quotes.
The same behaviour is implemented in Git bash which is a Windows port
of the bash shell.
2) Windows shells do not perform argument expansion. Instead, they try
to parse out the command and as soon as this succeeds, they call that
command and pass the rest of the command line to it as a single
string. Splitting it up to single arguments hence becomes the task
of the program itself.
Leaving aside discussing of the ways such a splitting might be done,
it suffuces to say that most sensible programs try to follow the
established Windows shell conventions, so, for instance, they won't
typically take a single quote to mean a grouping character.
In the end, I reckon that when the Git binary sees the string
commit -a -m 'Initial commit'
passed to it, it parses out *five* arguments from it: "commit", "-a",
"-m", "'Initial" and "commit'", without the quotes.
Hence your commit message becomes "'Initial" and "commit'" is treated
as a pathname, which conflicts with "-a".
So in the end the rule to follow is simple: if you're following a
tutorial on Git which assumes the presence of a POSIX shell, either use
Git bash or convert what you're reading to the Windows shell semantics.
It's not clear what point you were trying to make indeed.
So I made a guess and tried to explain why the behaviour differ between
different shells. If this is not what you tried to ask about feel free
to reformulate your question.