git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* howto to run git without a master branch
@ 2014-03-08 21:37 Carlos Pereira
  2014-03-09  7:46 ` Torsten Bögershausen
  0 siblings, 1 reply; 7+ messages in thread
From: Carlos Pereira @ 2014-03-08 21:37 UTC (permalink / raw)
  To: git

Hi,
git newbie here.

I would like to work with two main branches: master-g and master-x, 
instead of the usual master, and apparently git does not like this.

After creating a local repository with these two branches, and a server 
repository with git init --bare, and pushing the two branches:

git remote add origin foo@bar:~/path/test.git
git push origin master-g
git push origin master-x

everything seems fine, but cloning:
git clone foo@bar:~/path/test.git
terminates with a warning: remote HEAD refers to nonexistent ref, unable 
to checkout.

On the original local repository, I have:
 >cat HEAD
ref: refs/heads/master-x

But on the server repository or the clone repository, HEAD points to 
master branch, that does not exist:
 >cat HEAD
ref: refs/heads/master

Replacing in the HEAD file, master by master-g (on the server before 
cloning, or on the clone after cloning) seems to solve the problem.

Shall I worry about this? does my fix (editing directly HEAD on the 
server) fixes really the problem? what would be the correct procedure to 
avoid this?

Thank you!
Carlos Pereira,

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

* Re: howto to run git without a master branch
  2014-03-08 21:37 howto to run git without a master branch Carlos Pereira
@ 2014-03-09  7:46 ` Torsten Bögershausen
  2014-03-09 19:54   ` Carlos Pereira
  0 siblings, 1 reply; 7+ messages in thread
From: Torsten Bögershausen @ 2014-03-09  7:46 UTC (permalink / raw)
  To: Carlos Pereira, git

On 2014-03-08 22.37, Carlos Pereira wrote:
> Hi,
> git newbie here.
> 
> I would like to work with two main branches: master-g and master-x, instead of the usual master, and apparently git does not like this.
> 
> After creating a local repository with these two branches, and a server repository with git init --bare, and pushing the two branches:
> 
> git remote add origin foo@bar:~/path/test.git
> git push origin master-g
> git push origin master-x
> 
> everything seems fine, but cloning:
> git clone foo@bar:~/path/test.git
> terminates with a warning: remote HEAD refers to nonexistent ref, unable to checkout.
This is because Git is trying to be nice:
When you clone, it tries to checkout a branch for you.

What happens when you only have 1 branch, lets say master-x?
If I clone the bare repo here, with only 1 branch, this branch
is automatically checked out (tested on 1.8.5.2)

What happens when you have 2 branches on the server?
Git really can not make a decision which one is the right one to check out for
you, so if you have 2 branched like "master" and "develop", it checks out the
"master" branch for you.

But if you have "master-x" and "master-g" then Git has no clue, which one could
be you favorite one (and neither have I)

What does "git branch" say?
(I think nothing)
What does "git branch -r" say?
(I think "origin/master-g" and "origin/master-x")
  
> 
> On the original local repository, I have:
>>cat HEAD
> ref: refs/heads/master-x
> 
> But on the server repository or the clone repository, HEAD points to master branch, that does not exist:
>>cat HEAD
> ref: refs/heads/master
> 
> Replacing in the HEAD file, master by master-g (on the server before cloning, or on the clone after cloning) seems to solve the problem.
> 
> Shall I worry about this? does my fix (editing directly HEAD on the server) fixes really the problem? 

No

>what would be the correct procedure to avoid this?
(Don't worry if there is a warning, when Git tries to be nice)
(Or feel free to send a patch to this list which improves the user experience)

> 
> Thank you!
> Carlos Pereira,

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

* Re: howto to run git without a master branch
  2014-03-09  7:46 ` Torsten Bögershausen
@ 2014-03-09 19:54   ` Carlos Pereira
  2014-03-09 20:00     ` Kevin
  2014-03-09 22:16     ` Ilya Bobyr
  0 siblings, 2 replies; 7+ messages in thread
From: Carlos Pereira @ 2014-03-09 19:54 UTC (permalink / raw)
  To: Torsten Bögershausen; +Cc: git

On 03/09/2014 07:46 AM, Torsten Bögershausen wrote:
>> After creating a local repository with these two branches, and a server repository with git init --bare, and pushing the two branches:
>> >  
>> >  git remote add originfoo@bar:~/path/test.git
>> >  git push origin master-g
>> >  git push origin master-x
>> >  
>> >  everything seems fine, but cloning:
>> >  git clonefoo@bar:~/path/test.git
>> >  terminates with a warning: remote HEAD refers to nonexistent ref, unable to checkout.
>>      
> This is because Git is trying to be nice:
> When you clone, it tries to checkout a branch for you.
>
> What happens when you only have 1 branch, lets say master-x?
> If I clone the bare repo here, with only 1 branch, this branch
> is automatically checked out (tested on 1.8.5.2)
>
> What happens when you have 2 branches on the server?
> Git really can not make a decision which one is the right one to check out for
> you, so if you have 2 branched like "master" and "develop", it checks out the
> "master" branch for you.
>
> But if you have "master-x" and "master-g" then Git has no clue, which one could
> be you favorite one (and neither have I)
>    
The problem is on the server repo, the cloned repo is just a 
consequence. After initializing the server repo and pushing two branches 
master-g and master-x there is no master branch. Therefore the HEAD file 
should not point to a master branch that does not exist: ref: 
refs/heads/master

It could point to master-g (the first branch to be pushed) or master-x 
(the last branch to be pushed), depending of the criterion used by git, 
but pointing to something that does not exist seems weird and is the 
cause of the further complaints when the whole repository is cloned...

I forgot to say that the git version is 1.7.2.5 in both the initial repo 
and the server repo (probably this issue was fixed in newer versions?)

As I said, editing directly the HEAD text file on the server, and 
replacing master by master-g (or master-x) seems to solve the problem. 
My question is: is that enough? or shall I expect further issues down 
the road?

Thank you very much,

Carlos
> What does "git branch" say?
> (I think nothing)
> What does "git branch -r" say?
> (I think "origin/master-g" and "origin/master-x")
>
>    

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

* Re: howto to run git without a master branch
  2014-03-09 19:54   ` Carlos Pereira
@ 2014-03-09 20:00     ` Kevin
  2014-03-09 22:16     ` Ilya Bobyr
  1 sibling, 0 replies; 7+ messages in thread
From: Kevin @ 2014-03-09 20:00 UTC (permalink / raw)
  To: Carlos Pereira; +Cc: Torsten Bögershausen, git

HEAD on the remote repo is indeed used to determine what to check out
when cloning. It's quite normal to change it to anything you like. To
change it, you usually use git symbolic-ref HEAD master-x instead of
directly editing that file.

On Sun, Mar 9, 2014 at 8:54 PM, Carlos Pereira
<jose.carlos.pereira@ist.utl.pt> wrote:
> On 03/09/2014 07:46 AM, Torsten Bögershausen wrote:
>>>
>>> After creating a local repository with these two branches, and a server
>>> repository with git init --bare, and pushing the two branches:
>>> >  >  git remote add originfoo@bar:~/path/test.git
>>>
>>> >  git push origin master-g
>>> >  git push origin master-x
>>> >  >  everything seems fine, but cloning:
>>> >  git clonefoo@bar:~/path/test.git
>>>
>>> >  terminates with a warning: remote HEAD refers to nonexistent ref,
>>> > unable to checkout.
>>>
>>
>> This is because Git is trying to be nice:
>> When you clone, it tries to checkout a branch for you.
>>
>> What happens when you only have 1 branch, lets say master-x?
>> If I clone the bare repo here, with only 1 branch, this branch
>> is automatically checked out (tested on 1.8.5.2)
>>
>> What happens when you have 2 branches on the server?
>> Git really can not make a decision which one is the right one to check out
>> for
>> you, so if you have 2 branched like "master" and "develop", it checks out
>> the
>> "master" branch for you.
>>
>> But if you have "master-x" and "master-g" then Git has no clue, which one
>> could
>> be you favorite one (and neither have I)
>>
>
> The problem is on the server repo, the cloned repo is just a consequence.
> After initializing the server repo and pushing two branches master-g and
> master-x there is no master branch. Therefore the HEAD file should not point
> to a master branch that does not exist: ref: refs/heads/master
>
> It could point to master-g (the first branch to be pushed) or master-x (the
> last branch to be pushed), depending of the criterion used by git, but
> pointing to something that does not exist seems weird and is the cause of
> the further complaints when the whole repository is cloned...
>
> I forgot to say that the git version is 1.7.2.5 in both the initial repo and
> the server repo (probably this issue was fixed in newer versions?)
>
> As I said, editing directly the HEAD text file on the server, and replacing
> master by master-g (or master-x) seems to solve the problem. My question is:
> is that enough? or shall I expect further issues down the road?
>
> Thank you very much,
>
> Carlos
>
>> What does "git branch" say?
>> (I think nothing)
>> What does "git branch -r" say?
>> (I think "origin/master-g" and "origin/master-x")
>>
>>
>
>
> --
> 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

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

* Re: howto to run git without a master branch
  2014-03-09 19:54   ` Carlos Pereira
  2014-03-09 20:00     ` Kevin
@ 2014-03-09 22:16     ` Ilya Bobyr
  2014-03-09 23:58       ` Carlos Pereira
  2014-03-10  9:30       ` Andreas Schwab
  1 sibling, 2 replies; 7+ messages in thread
From: Ilya Bobyr @ 2014-03-09 22:16 UTC (permalink / raw)
  To: Carlos Pereira, Torsten Bögershausen; +Cc: git

On 3/9/2014 12:54 PM, Carlos Pereira wrote:
> On 03/09/2014 07:46 AM, Torsten Bögershausen wrote:
>>> After creating a local repository with these two branches, and a 
>>> server repository with git init --bare, and pushing the two branches:
>>> >  >  git remote add originfoo@bar:~/path/test.git
>>> >  git push origin master-g
>>> >  git push origin master-x
>>> >  >  everything seems fine, but cloning:
>>> >  git clonefoo@bar:~/path/test.git
>>> >  terminates with a warning: remote HEAD refers to nonexistent ref, 
>>> unable to checkout.
>> This is because Git is trying to be nice:
>> When you clone, it tries to checkout a branch for you.
>>
>> What happens when you only have 1 branch, lets say master-x?
>> If I clone the bare repo here, with only 1 branch, this branch
>> is automatically checked out (tested on 1.8.5.2)
>>
>> What happens when you have 2 branches on the server?
>> Git really can not make a decision which one is the right one to 
>> check out for
>> you, so if you have 2 branched like "master" and "develop", it checks 
>> out the
>> "master" branch for you.
>>
>> But if you have "master-x" and "master-g" then Git has no clue, which 
>> one could
>> be you favorite one (and neither have I)
> The problem is on the server repo, the cloned repo is just a 
> consequence. After initializing the server repo and pushing two 
> branches master-g and master-x there is no master branch. Therefore 
> the HEAD file should not point to a master branch that does not exist: 
> ref: refs/heads/master
>
> It could point to master-g (the first branch to be pushed) or master-x 
> (the last branch to be pushed), depending of the criterion used by 
> git, but pointing to something that does not exist seems weird and is 
> the cause of the further complaints when the whole repository is 
> cloned...

There is a "git remote set-head" to manipulate HEAD in a remote repository.

The fact that it is not set when you push master-x and master-y could be 
justified to some extent.
I think that this only applies to a case when you are pushing into a 
repository that have no branches.
Consider that you do not have to push only one branch, you may push any 
set of branches you want.  And I do not think that branches in the set 
have any meaningful order.
Also, your local HEAD does not necessary point to the "most reasonable 
branch to checkout when you clone".  It is just your current branch.
Now the questions is, how should the remote repository determine what to 
change HEAD to?

I agree that this might be viewed as a user experience issue.
But I can not come up with a possible solution.  Can you?

> I forgot to say that the git version is 1.7.2.5 in both the initial 
> repo and the server repo (probably this issue was fixed in newer 
> versions?)
>
> As I said, editing directly the HEAD text file on the server, and 
> replacing master by master-g (or master-x) seems to solve the problem. 
> My question is: is that enough? or shall I expect further issues down 
> the road?

I do not think there should be any issues.
Basically if your repository is not using master as the "most reasonable 
branch to checkout when you clone" you need to do "git remote set-head" 
when you are preparing the shared repository.
I guess that in most setups there will be just one shared repository.

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

* Re: howto to run git without a master branch
  2014-03-09 22:16     ` Ilya Bobyr
@ 2014-03-09 23:58       ` Carlos Pereira
  2014-03-10  9:30       ` Andreas Schwab
  1 sibling, 0 replies; 7+ messages in thread
From: Carlos Pereira @ 2014-03-09 23:58 UTC (permalink / raw)
  To: Ilya Bobyr; +Cc: Torsten Bögershausen, git, ikke


> There is a "git remote set-head" to manipulate HEAD in a remote 
> repository.
Thanks, that is useful (like git symbolic-ref HEAD master-x suggested by 
Kevin, much better than editing the text file)
> I agree that this might be viewed as a user experience issue.
> But I can not come up with a possible solution.  Can you?
The branch where the user was when he/she pushed the repo to the server? 
it would be his/her responsibility to checkout the proper branch before 
pushing... if that was not good enough than he/she could always use git 
remote set-head... my point is: pointing to a bad branch that exists 
seems better than pointing to a branch that does not exist...

Anyway I agree this is not important, as we can easily change HEAD.
> I do not think there should be any issues.
Thank you very much for your answers,

Carlos

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

* Re: howto to run git without a master branch
  2014-03-09 22:16     ` Ilya Bobyr
  2014-03-09 23:58       ` Carlos Pereira
@ 2014-03-10  9:30       ` Andreas Schwab
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2014-03-10  9:30 UTC (permalink / raw)
  To: Ilya Bobyr; +Cc: Carlos Pereira, Torsten Bögershausen, git

Ilya Bobyr <ilya.bobyr@gmail.com> writes:

> There is a "git remote set-head" to manipulate HEAD in a remote repository.

This is misleading.  The command does nothing on the remote side, it
only changes the refs/remote namespace in your repository.  The purpose
is to change what branch the ref remote/<name> resolves to, ie. without
explicit branch name.

(The only command that manipulates the remote repository is git push,
and the plumbing beneath that.  To change HEAD in a remote repository
you need filesystem access to it.)

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

end of thread, other threads:[~2014-03-10  9:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-08 21:37 howto to run git without a master branch Carlos Pereira
2014-03-09  7:46 ` Torsten Bögershausen
2014-03-09 19:54   ` Carlos Pereira
2014-03-09 20:00     ` Kevin
2014-03-09 22:16     ` Ilya Bobyr
2014-03-09 23:58       ` Carlos Pereira
2014-03-10  9:30       ` Andreas Schwab

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).