Re: git reset --keep (Re: What's cooking in git.git (Mar 2010, #01; Wed, 03))

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

 



On Friday 05 March 2010 17:25:21 Jonathan Nieder wrote:
>
> 1. Helping people new to git.
> 
> A person not very familiar with git comes to me asking how to undo
> the last couple of commits.  After a quick conversation, it becomes
> clear that the commits in question were not pushed out to any public
> repository and that this person does not feel it would be useful to
> publish the problem commits.
> 
> Currently, I would have to advise such a person to use
> 
> 	git reset --hard HEAD^^
> 
> I would prefer to recommend
> 
> 	git reset --keep HEAD^^
> 
> because if there are uncommitted changes then it will give a "needs
> update" message (right?) and I can help the person to deal with it.

If the uncommited changes are in files that are not touched by the discarded 
commits then it will silently work and will keep your uncommited changes.
If the uncommited changes are in files touched by the discarded commits then it 
will fail with an error message like this:

error: Entry 'foo' not uptodate. Cannot merge.
fatal: Could not reset index file to revision 'HEAD^^'.

Best regards,
Christian.
--
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]