Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was

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

 



On 2009.10.15 05:54:52 -0700, Jakub Narebski wrote:
> James Pickens <jepicken@xxxxxxxxx> writes:
> > Perhaps as an additional safety feature, Git could refuse to switch
> > away from a detached head if the head isn't reachable from any ref,
> > and require -f to override:
> > 
> > $ git checkout $sha1
> > $ git commit
> > $ git checkout master ;# complain
> > $ git checkout -f master ;# ok
> > 
> > Maybe I'm missing something and this all can't be done, but it seems simpler
> > than the other options I've seen in this thread.
> 
> I'm not sure about overloading '-f' option, unless we would require
> doubled '-f' for overriding both safety checks: checkout from detached
> HEAD, and current meaning of forcing a switch even if index or the
> working are differs from HEAD.  So you would need
> 
>   $ git checkout -f -f master
> 
> if you are on detached HEAD and have uncommitted changes (dirty tree 
> or dirty index).

A dirty index/worktree doesn't necessarily stop you from checking out a
different branch head/commit. Only if you have uncommitted changes to a
file that also has changes between HEAD and <other_branch>, git refuses
to switch. And if you want to keep your uncommitted changes, you want to
use -m (3-way merge), not -f (drop changes).

git checkout -f foo ~= git reset --hard && git checkout foo

So -f is most likely _not_ the flag one wants to overload.

Björn
--
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]