On Tue, Oct 13, 2009 at 11:28 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote: > When you do not have local "frotz" branch, and do have cloned/fetched from > the origin that has "frotz" branch, I am actually Ok with this > > $ git checkout frotz [--] > > to do an equivalent of: > > $ git checkout -t -b frotz origin/frotz > > I do not have problem with this _particular_ DWIMmery. It will not break > people's expectations, other than "asking to check out non-existing ref > should fail". That expectation might be logical, but I do not think it is > useful. > > Another reason I won't have problem with this one is that perhaps after > creating a few more commits, the next day when the user does the same > > $ git checkout frotz > > what will be shown is the _local_ frotz branch. Nowhere in this sequence > there is any room to mistake that you somehow checked out a branch owned > by somebody else (namely, origin). You started by auto-creating your > local branch, worked on it, and checked it out again the next day. In > other words, this is really about a shorthand to create a new local branch > called "frotz" when the commit that the branch should start from is > clearly unambiguous. Okay, this is good, and I can work up a patch if no one beats me to the punch. > I have trouble with yours, on the other hand, which is to make > > $ git checkout origin/frotz > $ git checkout v1.5.5 > > into > > $ git checkout -b frotz-47 origin/frotz > $ git checkout -b v1.5.5-47 v1.5.5 I suggested no such thing, at least, I don't think I did. What I said was: ---snip--- Modify checkout so that the first commit while detached automatically creates a branch. Perhaps the name is derived from the branch point, or the user is prompted for a name. ---snip--- So we'd only automatically create a new branch at commit time. But never mind that, it was just a suggestion and I don't like it. What if instead we do something like this: $ git checkout v1.5.5 Note: moving to 'v1.5.5' which isn't a local branch If you want to create a new branch from this checkout, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new_branch_name> HEAD is now at 1d2375d... GIT 1.5.5 $ [edit foo.c] $ git add foo.c $ git commit -m "edited some file" Cannot commit to v1.5.5. Please use git commit -b <branch> to specify the name of a new branch to commit to, or use git commit --detach to force a detached commit. So we modify git to, by default, no longer allow creating a commit while detached or on a branch that cannot be committed to. j. -- 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