Thread (10 messages) flat view 10 messages, 4 authors, 2016-06-15

Re: [1.8.0] Summary of the discussions

From: Martin von Zweigbergk <hidden>
Date: 2016-06-15 22:50:35

On Thu, 17 Feb 2011, Junio C Hamano wrote:
 * "git checkout refs/heads/<name>" checks out <name> branch.

    From: Martin von Zweigbergk [off-list ref]
    Date: Mon, 7 Feb 2011 06:01:51 -0500 (EST)
    Message-ID: <alpine.DEB.1.10.1102062234010.3788@debian>

    -- summary --

    In addition to "git checkout <name>" that names an existing branch,
    special case "git checkout refs/heads/<name>" to check the branch out,
At first I was going to say that I don't think special casing it
should be necessary. It seemed like as long as the name resolves to
something like refs/heads/<name>, the branch should be checked
out. Then I think I realized why you said to special case it. Since
checkout favors branches to tags, we would first have to check if
refs/heads/<arg> is valid and if it is not, check if the argument
resolves to refs/heads/<name> (maybe ignoring tags called
"heads/<name>").
    instead of detaching HEAD at the tip of the branch.  If you want to
    detach at a specific commit and wanted to disambiguate <name> that is
    both a branch and another ref by checking out refs/heads/<name>, your
    workflow will be broken by this change, but you can still say
    refs/heads/<name>^0 to work it around.

    -- comments --

    I do not think this backward incompatible breakage would seriously
    hurt in practice, and if people see newbies are hurt by getting a
    detached HEAD when they check out refs/heads/<name>, this proposal
    might be an improvement, but I have a feeling that this may be trying
    to solve a wrong problem.

    Why are these people _tempted_ to type refs/heads/ explicitly?  It
    could be our tutorial or documentation.  That might be the thing to
    fix.
It wasn't until recently that I learned that "git checkout
[refs/]heads/<name>" (and rebase <upstream> [refs/]heads/name)
detaches the head, so it wasn't really to try to help newbies that I
proposed changing it. It was just that the current behavior is not
what I think most people would expect.


/Martin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help