From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: Francis Galiegue <fge@one2team.com>
Cc: Mark Burton <markb@ordern.com>, git@vger.kernel.org
Subject: Re: Git commit won't add an untracked file given on the command line
Date: Tue, 18 Nov 2008 23:16:07 +0100 [thread overview]
Message-ID: <vpq8wrg7k9k.fsf@bauges.imag.fr> (raw)
In-Reply-To: <200811182227.20076.fge@one2team.com> (Francis Galiegue's message of "Tue\, 18 Nov 2008 22\:27\:19 +0100")
Francis Galiegue <fge@one2team.com> writes:
> Le Tuesday 18 November 2008 22:12:37 Mark Burton, vous avez écrit :
>> Hi,
>>
>> When I try:
>>
>> git commit -m "New file." .gitignore
>>
>> Where .gitignore is not yet tracked, I get:
>>
>> error: pathspec '.gitignore' did not match any file(s) known to git.
>>
>> Is that result by design, sloth or bug (or me being stupid)?
>>
>
> You must "git add .gitignore" first. And yes, this is by design.
If it's by design, then it's a documentation bug:
-o, --only
Make a commit only from the paths specified on the
command line, disregarding any contents that have been
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
staged so far. This is the default mode of operation of
^^^^^^^^^^^^^
git-commit if any paths are given on the command line,
We have here a case where having staged content before doing commit -o
actually changes its behavior.
Looking at the code, this happens because the "file" list is actually
a pattern list (so that you can "git commit '*.txt'" or so), and the
pattern is looked for in the index (the error is raised in
"list_paths").
> You could also have done git commit -a -m "themessage".
Well, he could have done that, but then the result would have been
different ;-).
--
Matthieu
prev parent reply other threads:[~2008-11-18 22:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-18 21:12 Git commit won't add an untracked file given on the command line Mark Burton
2008-11-18 21:27 ` Francis Galiegue
2008-11-18 21:47 ` Mark Burton
2008-11-19 1:07 ` Johannes Schindelin
2008-11-19 1:21 ` Miles Bader
2008-11-19 1:39 ` Johannes Schindelin
2008-11-19 3:43 ` Miles Bader
2008-11-19 9:41 ` Johannes Schindelin
2008-11-20 5:06 ` Miles Bader
2008-11-19 1:51 ` Junio C Hamano
2008-11-19 9:54 ` Mark Burton
2008-11-19 11:27 ` Johannes Schindelin
2008-11-19 13:22 ` Junio C Hamano
2008-11-19 14:41 ` Mark Burton
2008-11-19 18:01 ` Daniel Barkalow
2008-11-19 23:07 ` Junio C Hamano
2008-11-19 23:30 ` Mark Burton
2008-11-19 23:51 ` Junio C Hamano
2008-11-19 23:52 ` Daniel Barkalow
2008-11-20 0:36 ` Junio C Hamano
2008-11-20 10:18 ` David Aguilar
2008-11-18 22:16 ` Matthieu Moy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpq8wrg7k9k.fsf@bauges.imag.fr \
--to=matthieu.moy@imag.fr \
--cc=fge@one2team.com \
--cc=git@vger.kernel.org \
--cc=markb@ordern.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox