Re: Dangers of reset --hard (Re: Implicit stashes)

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

 



Will Palmer wrote:

> I tend to want "do a git reset --hard, but fail if anything would be
> lost".

At the risk of being redundant: try git reset --keep.  If it succeeds,
you can use git diff --cached HEAD and git diff to check how close it
was to being equivalent to a hard reset.

> The use-case here is that when I reset --hard, I want a
> completely clean copy- but I don't want to accidentally lose anything.

There is one case when I truly want a completely clean copy (including
no untracked files): when I am testing and a bit paranoid.  For that,
I do something like the following:

 ; mkdir /tmp/test-dir
 ; git archive HEAD | (cd /tmp/test-dir && tar -xf -)
 ; cd /tmp/test-dir

and work from there.  I would not be surprised if the needs of your
case are different, though.
--
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]