From: Jared Hance <jaredhance@gmail.com>
To: git@vger.kernel.org
Subject: Re: Can I checkout a single file without altering index?
Date: Wed, 13 Oct 2010 17:09:07 +0000 (UTC) [thread overview]
Message-ID: <loom.20101013T190544-893@post.gmane.org> (raw)
In-Reply-To: 4CB44318.7000305@atlas-elektronik.com
Stefan Naewe <stefan.naewe <at> atlas-elektronik.com> writes:
>
> On 10/12/2010 12:03 PM, Christian Halstrick wrote:
> > Can I checkout a certain file to a specific revision without also adding
this
> > content to the index? I only want to alter the working-tree - no
modification of
> > index or HEAD needed.
> >
> > Here is why I need that: I see a bug in git controlled sources. I fix one
source
> > file and also add one unit test in a separate file. I checked that the test
> > succeeds with my fix. The index now contains what I want to commit.
> > Now I want to see whether my test fails without my fix. I want to checkout
HEAD
> > for the source file without destroying my index. In the end, after I saw
that my
> > test fails without my fix, I just want to say "git commit" without having
to.
>
> commit the unit test first, and the fix as a second commit ?
>
> Regards,
> Stefan
Just to add to this, since you might not want the test and the fix in separate
commmits: (as is implied in the message)
1. commit unit test.
2. commit fix.
3. go to detchatched head at HEAD^
4. run unit test to insure that it fails.
5. checkout the branch again to where you have the fix.
6. run unit test to insure that it doesn't fail.
7. run `git rebase HEAD^` and merge squash the two commits. (optional)
Alternatively, as others have pointed out, the stash should work as well.
next prev parent reply other threads:[~2010-10-13 17:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-12 10:03 Can I checkout a single file without altering index? Christian Halstrick
2010-10-12 10:19 ` Michael J Gruber
2010-10-12 11:14 ` Stefan Naewe
2010-10-13 17:09 ` Jared Hance [this message]
2010-10-12 15:39 ` Alex Riesen
2010-10-12 16:39 ` Tomas Carnecky
2010-10-14 8:03 ` Christian Halstrick
2010-10-15 18:30 ` Neal Kreitzinger
2010-10-15 18:43 ` Jonathan Nieder
2010-10-15 18:55 ` Jeff King
2010-10-15 19:32 ` Jonathan Nieder
2010-10-15 19:48 ` Jeff King
2010-10-15 18:57 ` Neal Kreitzinger
2010-10-15 19:02 ` Andreas Schwab
2010-10-15 23:22 ` Junio C Hamano
2010-10-15 23:40 ` Jonathan Nieder
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20101013T190544-893@post.gmane.org \
--to=jaredhance@gmail.com \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).