* how to start with non-master branch?
@ 2009-07-19 12:53 Rustom Mody
2009-07-19 16:13 ` Dirk Süsserott
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Rustom Mody @ 2009-07-19 12:53 UTC (permalink / raw)
To: git
I want my first commit to be on a non-master branch.
So after the git init I do
$ git checkout -b newbranch
I get
fatal: You are on a branch yet to be born
Of course I can get by with making the first commit on master and then
switching.
But wondering if I am missing something basic?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to start with non-master branch?
2009-07-19 12:53 how to start with non-master branch? Rustom Mody
@ 2009-07-19 16:13 ` Dirk Süsserott
2009-07-19 16:19 ` Sean Estabrooks
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Dirk Süsserott @ 2009-07-19 16:13 UTC (permalink / raw)
To: Rustom Mody; +Cc: git
Am 19.07.2009 14:53 schrieb Rustom Mody:
> I want my first commit to be on a non-master branch.
> So after the git init I do
> $ git checkout -b newbranch
>
> I get
> fatal: You are on a branch yet to be born
>
> Of course I can get by with making the first commit on master and then
> switching.
>
> But wondering if I am missing something basic?
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
What about renaming the "initial master", i.e.:
git init
git add .
git commit -m "intial checkin"
git branch -m non-master-branch
and later adding a master just as any other branch, i.e.
git checkout -b master
Unfortunately renaming doesn't work before the first commit, I got an
error similar to yours.
I think the name "master" is just a convention and there's nothing
special about that branch. Could've been called "main" or sth. as well
when Linus invented it.
Dirk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to start with non-master branch?
2009-07-19 12:53 how to start with non-master branch? Rustom Mody
2009-07-19 16:13 ` Dirk Süsserott
@ 2009-07-19 16:19 ` Sean Estabrooks
2009-07-19 17:44 ` Charles Bailey
2009-07-19 18:26 ` Michael J Gruber
3 siblings, 0 replies; 5+ messages in thread
From: Sean Estabrooks @ 2009-07-19 16:19 UTC (permalink / raw)
To: Rustom Mody; +Cc: git
On Sun, 19 Jul 2009 18:23:32 +0530
Rustom Mody <rustompmody@gmail.com> wrote:
Hi Rustom,
> I want my first commit to be on a non-master branch.
> So after the git init I do
> $ git checkout -b newbranch
>
> I get
> fatal: You are on a branch yet to be born
No branches exist in a new repository that you've just init'ed. If you run
"git branch" you'll see that no branches are listed. You must make an
initial commit before a branch will be "born". Since "git checkout"
needs you to supply a branch/commit to operate, you can't use it to create
the first branch in a repo.
When you make the initial commit in a repo the HEAD reference will
determine which branch is created. So the following ugly looking
command will allow you to change the name to something other than
master before making your first commit:
$ git symbolic-ref HEAD refs/heads/newbranch
> Of course I can get by with making the first commit on master and then
> switching.
That is probably the simplest thing to do, rename master after the initial
commit:
$ git commit -m "initial commit"
$ git branch -m newbranch
HTH,
Sean
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to start with non-master branch?
2009-07-19 12:53 how to start with non-master branch? Rustom Mody
2009-07-19 16:13 ` Dirk Süsserott
2009-07-19 16:19 ` Sean Estabrooks
@ 2009-07-19 17:44 ` Charles Bailey
2009-07-19 18:26 ` Michael J Gruber
3 siblings, 0 replies; 5+ messages in thread
From: Charles Bailey @ 2009-07-19 17:44 UTC (permalink / raw)
To: Rustom Mody; +Cc: git
On Sun, Jul 19, 2009 at 06:23:32PM +0530, Rustom Mody wrote:
> I want my first commit to be on a non-master branch.
> So after the git init I do
> $ git checkout -b newbranch
>
> I get
> fatal: You are on a branch yet to be born
>
> Of course I can get by with making the first commit on master and then
> switching.
>
> But wondering if I am missing something basic?
The problem with git checkout -b newbranch is that it tries to create
a new branch based on your current HEAD. As you have no commits, your
HEAD doesn't point at a commit ant this can't work. To change the name
of your current branch before you've made any commits, you can use the
symbolic-ref command to update your HEAD to point to a differently
named branch (that also doesn't yet exist). Try this:
git symbolic-ref HEAD refs/heads/non-master
and then carry on adding and committing as before.
Charles.
--
Charles Bailey
http://ccgi.hashpling.plus.com/blog/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to start with non-master branch?
2009-07-19 12:53 how to start with non-master branch? Rustom Mody
` (2 preceding siblings ...)
2009-07-19 17:44 ` Charles Bailey
@ 2009-07-19 18:26 ` Michael J Gruber
3 siblings, 0 replies; 5+ messages in thread
From: Michael J Gruber @ 2009-07-19 18:26 UTC (permalink / raw)
To: Rustom Mody; +Cc: git
Rustom Mody venit, vidit, dixit 19.07.2009 14:53:
> I want my first commit to be on a non-master branch.
> So after the git init I do
> $ git checkout -b newbranch
>
> I get
> fatal: You are on a branch yet to be born
>
> Of course I can get by with making the first commit on master and then
> switching.
>
> But wondering if I am missing something basic?
You can do
git symbolic-ref HEAD refs/heads/newbranch
and your first commit will be to that branch. (checkout as above tries
to branch off the non-existing branch master.)
Cheers,
Michael
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-07-19 18:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-19 12:53 how to start with non-master branch? Rustom Mody
2009-07-19 16:13 ` Dirk Süsserott
2009-07-19 16:19 ` Sean Estabrooks
2009-07-19 17:44 ` Charles Bailey
2009-07-19 18:26 ` Michael J Gruber
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).