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

wishlist: "--cached|--staged" to "git commit file(s)"

From
Yaroslav Halchenko <yoh@onerussian.com>
Date
Aug 13, 2018, 16:22 UTC
Message-ID
<20180813162236.GO732@hopa.kiewit.dartmouth.edu>
Dear Git developers,

Following up on my quick question/discussion on IRC a few days back: Please consider adding --cached or --staged option for

git commit file(s)

command. ATM there is no non-interactive (via --patch/--interactive I think it is possible) way to commit selected subset of staged files not from the worktree (as it is done with "git commit file(s)") but from the index.

Original usecase (I would be happy to elaborate): committing specified by user files in "direct" mode of git-annex, where it (via git annex add) first converts files to the symlinks within index (they remain original files within worktree), so we cannot use "git commit file(s)" since then they would get committed disregarding their state in index.

But thinking about it I realized that it was quite a common use case to me, that I typically stage all modified files whenever I reach "it is no longer broken" stage, and then decide to commit that staged state in a number of separate commits, and only then commit worktree state.

Current workaround as suggested on IRC is to 
- cp .git/index .git/index2
- GIT_INDEX_FILE=.git/index2 git reset files_not_to_be_committed
- GIT_INDEX_FILE=.git/index2 git commit
- rm .git/index2
or may be there is another (better) way?
-- 
Yaroslav O. Halchenko
Center for Open Neuroscience     http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        
Next: Junio C Hamano
Message 1 of 3 in “wishlist: "--cached|--staged" to "git commit file(s)"”
  1. Yaroslav HalchenkoAug 13, 2018
  2. Junio C HamanoAug 13, 2018
  3. Yaroslav HalchenkoAug 14, 2018

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.