Re: Is it possible to roll back unstaged changes while leaving the staged ones for the next commit?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 17, 2008 at 3:30 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> The last part of the sentence after "because" does not parse for me at
> all...

Sorry for the double/triple/quadruple negatives I threw in there.
Makes the statement incredibly unclear.

> , but I think you are after one of the following:
>
>  (1) if you want to get rid of garbage changes in your work tree, you
>     would want "git checkout $that_path";
>
>  (2) if you want to temporarily stash away further changes in your work
>     tree, because you would want to first test what is staged, commit it,
>     and then later continue to refine the changes stashed away thusly,
>     you would want "git stash --keep-index".
>
>

If I could attempt to make my situation a little clearer.

I had two very similar files (I know, I know, DRY, blah blah. :\ It's
not my source tree to begin with... bleh) and I wanted to duplicate a
bunch of simple edits (adding white space, comments, etc.) from one of
them to the other without having to manually compare them.

Then, a light bulb went off in my head and I thought to myself that it
would make a ton of sense to use `git add -i` to add only the changes
that I wanted to the files and leave the stuff I wanted to be
different between the two of them out.  I `cp`ed the edited file over
the other file and then fired up `git add -i` and proceeded to stage
all of the edits that I wanted.  This left me with a staged version of
the file that was exactly what I wanted and a locally modified file
with contents that I didn't want.  However, the changes were still
untested.

What I wanted to do was basically get rid of the unstaged edits on
this file but keep the staged ones.  Without committing.

Unfortunately I couldn't figure out how to do this.  The solution I
came up with was to go ahead and `git commit` the staged changes and
then `git checkout PATH` the just committed file to overwrite the
local edits with the version of the file I wanted.

I want to know if it was possible to accomplish this without the commit stage.

-- 

In Christ,

Timmy V.

http://burningones.com/
http://five.sentenc.es/ - Spend less time on e-mail
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux