threads / discuss / 16638

Can someone confirm what the contents of refs/heads/master means?

Subject: Can someone confirm what the contents of refs/heads/master means?

## tl;dr

6 messages between Dec 8, 2008 and Dec 8, 2008.

replies: 5people: 3as markdown or json

davetron5000· Dec 8, 2008, 19:23 UTC · lore
I'm using git-svn to interact with an SVN repo that has branches.
After my clone via:
git svn clone $REPO/main -T trunk -b branches -t tags

my 'master' branch pointed to one of the branches in svn and not to the main trunk. (my .git/config looked correct for svn interaction, i.e. trunk pointed to the right place).

So, I overwrote refs/heads/master with the contents of refs/remotes/ trunk (i.e. the SHA-1 of the svn trunk).

Things seem to be working; git svn dcommit commits to the trunk and git svn rebase updates from svn's trunk.

So, I want to make sure that refs/heads/master actuall does, in fact, point to the head revision of whatever branch is considered "master". Can someone comfirm this (or provide the actual explanation if I'm wrong?)

Thanks!
Dave
Peter Harris· Dec 8, 2008, 19:35 UTC · re: davetron5000 · lore

Re: Can someone confirm what the contents of refs/heads/master means?

On Mon, Dec 8, 2008 at 2:23 PM, davetron5000 wrote:
Show 9 quoted lines
>
> So, I overwrote refs/heads/master with the contents of refs/remotes/
> trunk (i.e. the SHA-1 of the svn trunk).
>
> Things seem to be working; git svn dcommit commits to the trunk and
> git svn rebase updates from svn's trunk.
>
> So, I want to make sure that refs/heads/master actuall does, in fact,
> point to the head revision of whatever branch is considered "master".
I do believe so, yes. That, or an entry in packed-refs.
> Can someone comfirm this (or provide the actual explanation if I'm
> wrong?)

Overwriting internal files by hand feels a little too much like work for my taste. I would have done something more like "git reset --hard trunk" (or, if not on master, "git branch -D master; git branch master trunk" ), but of course you can feel free to do things the hard way if you prefer. :-)

Peter Harris
David Copeland· Dec 8, 2008, 19:42 UTC · re: Peter Harris · lore

Re: Can someone confirm what the contents of refs/heads/master means?

Thanks for the info :)

The reason I edited by hand is when I was on trunk (e.g. git checkout trunk), I did a git svn dcommit and it worked, but said "you aren't on a branch", so I was concerned I might be in some weird state (i.e. if trunk isn't a branch, can I make a branch off of it?)

Dave
On Mon, Dec 8, 2008 at 2:35 PM, Peter Harris <git@peter.is-a-geek.org> wrote:
Show 24 quoted lines
> On Mon, Dec 8, 2008 at 2:23 PM, davetron5000 wrote:
>>
>> So, I overwrote refs/heads/master with the contents of refs/remotes/
>> trunk (i.e. the SHA-1 of the svn trunk).
>>
>> Things seem to be working; git svn dcommit commits to the trunk and
>> git svn rebase updates from svn's trunk.
>>
>> So, I want to make sure that refs/heads/master actuall does, in fact,
>> point to the head revision of whatever branch is considered "master".
>
> I do believe so, yes. That, or an entry in packed-refs.
>
>> Can someone comfirm this (or provide the actual explanation if I'm
>> wrong?)
>
> Overwriting internal files by hand feels a little too much like work
> for my taste. I would have done something more like "git reset --hard
> trunk" (or, if not on master, "git branch -D master; git branch master
> trunk" ), but of course you can feel free to do things the hard way if
> you prefer. :-)
>
> Peter Harris
>
Peter Harris· Dec 8, 2008, 19:55 UTC · re: David Copeland · lore

Re: Can someone confirm what the contents of refs/heads/master means?

On Mon, Dec 8, 2008 at 2:42 PM, David Copeland wrote:
Show 6 quoted lines
> Thanks for the info :)
>
> The reason I edited by hand is when I was on trunk (e.g. git checkout
> trunk), I did a git svn dcommit and it worked, but said "you aren't on
> a branch", so I was concerned I might be in some weird state (i.e. if
> trunk isn't a branch, can I make a branch off of it?)

Trunk is a "remote branch", so you can't check it out. If you try, you get what is called a "detached HEAD".

http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#detached-head
And, yes, you can make a local branch off of a remote branch.
Peter Harris
Björn Steinbrink· Dec 8, 2008, 21:26 UTC · re: davetron5000 · lore

Re: Can someone confirm what the contents of refs/heads/master means?

On 2008.12.08 11:23:46 -0800, davetron5000 wrote:
Show 9 quoted lines
> I'm using git-svn to interact with an SVN repo that has branches.
> 
> After my clone via:
> 
> git svn clone $REPO/main -T trunk -b branches -t tags
> 
> my 'master' branch pointed to one of the branches in svn and not to
> the main trunk. (my .git/config looked correct for svn interaction,
> i.e. trunk pointed to the right place).

Just to clear up that bit as well. when the "fetch" finishes (which is part of the clone process), git-svn checks if there is a master branch, and if not, it creates one from the last commit it created. So if your last svn commit was to branch XYZ and not to trunk, master will reference that commit on branch XYZ.

Björn
David Copeland· Dec 8, 2008, 22:21 UTC · re: Björn Steinbrink · lore

Re: Can someone confirm what the contents of refs/heads/master means?

Ah, that makes sense (I did another clone of another repo and did not experience this behavior, so now that all makes sense).

Thanks!
Dave
On Mon, Dec 8, 2008 at 4:26 PM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
Show 19 quoted lines
> On 2008.12.08 11:23:46 -0800, davetron5000 wrote:
>> I'm using git-svn to interact with an SVN repo that has branches.
>>
>> After my clone via:
>>
>> git svn clone $REPO/main -T trunk -b branches -t tags
>>
>> my 'master' branch pointed to one of the branches in svn and not to
>> the main trunk. (my .git/config looked correct for svn interaction,
>> i.e. trunk pointed to the right place).
>
> Just to clear up that bit as well. when the "fetch" finishes (which is
> part of the clone process), git-svn checks if there is a master branch,
> and if not, it creates one from the last commit it created. So if your
> last svn commit was to branch XYZ and not to trunk, master will
> reference that commit on branch XYZ.
>
> Björn
>

← back to recent threads