git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* creation of empty branches
@ 2012-11-14 10:10 Angelo Borsotti
  2012-11-14 12:54 ` Andrew Ardill
  0 siblings, 1 reply; 5+ messages in thread
From: Angelo Borsotti @ 2012-11-14 10:10 UTC (permalink / raw)
  To: git

Hi,

the man page of git checkout does not describe the behavior of
git-checkout when asked to create empty branches. E.g.:

$ git init myrepo
$ cd myrepo
$ git checkout -b newbranch

the last command actually changes only the HEAD. It displays no output
telling the user that no switch to a new branch is done. Moreover, it
can be entered again without receiving any error message (unlike the
creation ot non-empty branches, which is instead rejected).
I would suggest to add to the DESCRIPTION, after the paragraph: "If -b
is given ...":

    "If the repository does not contain any branch, no new branch is
created, but the HEAD is set to refer to it."

Moreover, it is often reported (e.g. in the progit book) that git
checkout -b is equivalent to git branch; git checkout, and this is
true when nonempty branches are created, but it is not when the
repository is empty:

$ git init myrepo
$ cd myrepo
$ git branch master
fatal: Not a valid object name: 'master'.

however:
$ git checkout -b master
.... no error

This seems quite strange and difficult to understand: why should git
branch master issue an error while git checkout does not? I have the
impression that also git branch should not issue an error in this
case.

-Angelo Borsotti

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-15 17:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-14 10:10 creation of empty branches Angelo Borsotti
2012-11-14 12:54 ` Andrew Ardill
2012-11-14 21:27   ` Junio C Hamano
2012-11-15  0:04     ` Andrew Ardill
2012-11-15 17:12     ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).