From: Jonathan Nieder Date: Fri, 15 Oct 2010 23:40:08 GMT Subject: Re: Can I checkout a single file without altering index? Message-ID: <20101015234008.GC25624@burratino> In-Reply-To: <7viq13avn0.fsf@alter.siamese.dyndns.org> Junio C Hamano wrote: > 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