git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git commit --only -- $path when $path already has staged content

From
Stefan Näwe <stefan.naewe@atlas-elektronik.com>
Date
Nov 7, 2014, 10:38 UTC
Message-ID
<545CA118.6040500@atlas-elektronik.com>
Hello.
The manpage of git commit reads:
  --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, in which case this option can be omitted. [...]

But that seems to be only true for other content (i.e. other files not specified in the command line).

If I do:
    # some repo with a file in it
    git init
    echo content >foo && git add foo && git commit -m foo
    # modify and stage a file
    echo other >> foo && git add foo
    # modify the same file even further but don't stage
    echo bar >> foo
    # commit with path specified on command line with explicit '--only'
    git commit --only -m'.' -- foo
    # but everything was commited
    git status -s
    <empty>

I would expect to only get the unstaged changes in the commit. Could anyone shed some light, please?

Thanks,
  Stefan
-- 
----------------------------------------------------------------
/dev/random says: Useless Invention: Camcorder with braile-encoded buttons.
python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')" 
GPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9  9666 829B 49C5 9221 27AF
Next: Junio C Hamano
Message 1 of 5 in “git commit --only -- $path when $path already has staged content”
  1. Stefan NäweNov 7, 2014
  2. Junio C HamanoNov 7, 2014
  3. Junio C HamanoNov 7, 2014
  4. Junio C HamanoNov 7, 2014
  5. Stefan NäweNov 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.