From: Angelo Borsotti <angelo.borsotti@gmail.com>
To: git <git@vger.kernel.org>
Subject: creation of empty branches
Date: Wed, 14 Nov 2012 11:10:07 +0100 [thread overview]
Message-ID: <CAB9Jk9CaBECT7c_M9HvCbB8mFYGvdsmq_jFW4DF4NCO8Narnmw@mail.gmail.com> (raw)
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
next reply other threads:[~2012-11-14 10:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-14 10:10 Angelo Borsotti [this message]
2012-11-14 12:54 ` creation of empty branches Andrew Ardill
2012-11-14 21:27 ` Junio C Hamano
2012-11-15 0:04 ` Andrew Ardill
2012-11-15 17:12 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAB9Jk9CaBECT7c_M9HvCbB8mFYGvdsmq_jFW4DF4NCO8Narnmw@mail.gmail.com \
--to=angelo.borsotti@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).