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

Re: Can I checkout a single file without altering index?

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 15, 2010, 23:40 UTC
Message-ID
<20101015234008.GC25624@burratino>
In-Reply-To
<7viq13avn0.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
Show 15 quoted lines
>                                                           If somebody
> can write a convincing use case that shows why it is useful, such an
> option shouldn't be very hard to add.  But I don't think of any.  For
> example, this is not it:
> 
>     I start from a clean slate and start working.
> 
>     $ git checkout
>     $ edit; git diff; compile; test; git add path ;# repeat
> 
>     At this point I have some cooked contents added for the next commit
>     in the index for path.  But I realize that the contents of that path
>     in another branch might be even better.  But I do not want to lose
>     the state I arrived at, which might be better than that alternative.
>     I cannot decide, so I'll keep that in the index for now.
To be a devil's advocate (because I am not convinced yet), here is one:
    I start from a clean slate and start working.
    $ git checkout
    $ edit; git diff; compile; test; git add path ;# repeat
    At this point I have some cooked contents added for the next commit
    in the index for path.  Illustrating the new change is a new test,
    and I want to "test the test" by trying it out against the inferior
    previous state.
    $ git checkout --no-index HEAD path
    $ test; edit test; git diff; compile; test; git add test ;# repeat
    Now one last test run with the improved state
    $ git checkout path
    $ compile; test
    $ git commit
Previous: Junio C Hamano
Message 16 of 16 in “Can I checkout a single file without altering index?”
  1. Christian HalstrickOct 12, 2010
  2. Michael J GruberOct 12, 2010
  3. Stefan NaeweOct 12, 2010
  4. Jared HanceOct 13, 2010
  5. Alex RiesenOct 12, 2010
  6. Tomas CarneckyOct 12, 2010
  7. Christian HalstrickOct 14, 2010
  8. Neal KreitzingerOct 15, 2010
  9. Jonathan NiederOct 15, 2010
  10. Jeff KingOct 15, 2010
  11. Jonathan NiederOct 15, 2010
  12. Jeff KingOct 15, 2010
  13. Neal KreitzingerOct 15, 2010
  14. Andreas SchwabOct 15, 2010
  15. Junio C HamanoOct 15, 2010
  16. Jonathan NiederOct 15, 2010

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.