threads / discuss / 20699

git svn pointing at svn branch instead of trunk?

Subject: git svn pointing at svn branch instead of trunk?

## tl;dr

5 messages between Aug 22, 2009 and Aug 30, 2009.

replies: 4people: 3as markdown or json

skillzero@gmail.com· Aug 22, 2009, 18:40 UTC · lore

When I used git svn to clone a repository, it ended up pointing master at a tag in svn instead of trunk. For example, git svn info shows the URL for the tag instead of trunk. git log master also shows the most recent commit is the creation of that tag in svn, but then the next commit is the most recent commit to trunk. It's like it's mixing things from the tag with things from trunk. The most recent commit in svn was to create the tag that master is now pointing to in case that matters.

Is there something in the svn repository that might cause this? What's the correct way to reset what git svn thinks master should point to? And how should I get rid of the commit on master that created the tag without messing up git svn (e.g. can I just git reset or will that confuse git svn later?).

Eric Wong· Aug 22, 2009, 20:46 UTC · re: skillzero@gmail.com · lore

Re: git svn pointing at svn branch instead of trunk?

skillzero@gmail.com wrote:
Show 8 quoted lines
> When I used git svn to clone a repository, it ended up pointing master
> at a tag in svn instead of trunk. For example, git svn info shows the
> URL for the tag instead of trunk. git log master also shows the most
> recent commit is the creation of that tag in svn, but then the next
> commit is the most recent commit to trunk. It's like it's mixing
> things from the tag with things from trunk. The most recent commit in
> svn was to create the tag that master is now pointing to in case that
> matters.
Hi,
So you have something like this?
----------trunk
              \
               \-> tag

It looks like it's mixed but that's because trunk is an ancestor of your tag, so the majority of commits (see git-svn-id:) look like they're from trunk except the latest git-svn-id: which should have the URL of the tag in it. So in short, everything here is OK.

Show 5 quoted lines
> Is there something in the svn repository that might cause this? What's
> the correct way to reset what git svn thinks master should point to?
> And how should I get rid of the commit on master that created the tag
> without messing up git svn (e.g. can I just git reset or will that
> confuse git svn later?).

I changed this recently in b186a261b1f7ec1fbda8c5f6d84595f3a7716d92 git svn used to always pick the newest change in the entire SVN repo to point master to, now it'll attempt to find "trunk" to be master.

You can git reset anything on your master without affecting git svn.

If you have commits on master, just cherry pick them to a new branch that's based off trunk and then reset master to be that new branch.

-- 
Eric Wong
skillzero@gmail.com· Aug 22, 2009, 22:12 UTC · re: Eric Wong · lore

Re: git svn pointing at svn branch instead of trunk?

On Sat, Aug 22, 2009 at 1:46 PM, Eric Wong<normalperson@yhbt.net> wrote:
Show 10 quoted lines
> So you have something like this?
>
> ----------trunk
>              \
>               \-> tag
>
> It looks like it's mixed but that's because trunk is an ancestor of your
> tag, so the majority of commits (see git-svn-id:) look like they're from
> trunk except the latest git-svn-id: which should have the URL of the tag
> in it.  So in short, everything here is OK.

Yes, that's what I see: most of the commits have a /trunk URL except the last one has a /tags/TagX URL.

When the next commit happens on master (I don't have svn commit access on the svn repo to try it myself), will git svn automatically track master->trunk again? Or is there something I need to change to tell it "master tracks svn's /trunk"? I normally do git svn fetch and git svn rebase (while on master, I do all my own commits on a separate branch).

> I changed this recently in b186a261b1f7ec1fbda8c5f6d84595f3a7716d92
> git svn used to always pick the newest change in the entire SVN repo
> to point master to, now it'll attempt to find "trunk" to be master.
Thanks, I'll build that and try it out. That sounds like what was confusing me.
Eric Wong· Aug 23, 2009, 02:51 UTC · re: skillzero@gmail.com · lore

Re: git svn pointing at svn branch instead of trunk?

skillzero@gmail.com wrote:
Show 22 quoted lines
> On Sat, Aug 22, 2009 at 1:46 PM, Eric Wong<normalperson@yhbt.net> wrote:
> 
> > So you have something like this?
> >
> > ----------trunk
> >              \
> >               \-> tag
> >
> > It looks like it's mixed but that's because trunk is an ancestor of your
> > tag, so the majority of commits (see git-svn-id:) look like they're from
> > trunk except the latest git-svn-id: which should have the URL of the tag
> > in it.  So in short, everything here is OK.
> 
> Yes, that's what I see: most of the commits have a /trunk URL except
> the last one has a /tags/TagX URL.
> 
> When the next commit happens on master (I don't have svn commit access
> on the svn repo to try it myself), will git svn automatically track
> master->trunk again? Or is there something I need to change to tell it
> "master tracks svn's /trunk"? I normally do git svn fetch and git svn
> rebase (while on master, I do all my own commits on a separate
> branch).

You need to reset your master to trunk so it knows to track trunk instead of tags/TagX

-- 
Eric Wong
Daniele Segato· Aug 30, 2009, 20:30 UTC · re: skillzero@gmail.com · lore

Re: git svn pointing at svn branch instead of trunk?

Il giorno sab, 22/08/2009 alle 11.40 -0700, skillzero@gmail.com ha scritto:

Show 8 quoted lines
> When I used git svn to clone a repository, it ended up pointing master
> at a tag in svn instead of trunk. For example, git svn info shows the
> URL for the tag instead of trunk. git log master also shows the most
> recent commit is the creation of that tag in svn, but then the next
> commit is the most recent commit to trunk. It's like it's mixing
> things from the tag with things from trunk. The most recent commit in
> svn was to create the tag that master is now pointing to in case that
> matters.
I had the same problem a while ago.

When git-svn is done cloning you find yourself in the "master" branch (check by executing git branch) and it's content is the last svn-commit. If the last svn commit is a tag or in a branch you'll end up in that tag/branch

Show 5 quoted lines
> Is there something in the svn repository that might cause this? What's
> the correct way to reset what git svn thinks master should point to?
> And how should I get rid of the commit on master that created the tag
> without messing up git svn (e.g. can I just git reset or will that
> confuse git svn later?).

execute: git branch -r

it will list all the remote branches:
usually one will be "trunk"
if you now execute:
git reset --hard remotes/trunk

it will reset your current local branch (master) to the remote trunk and will start to truck that remote branch (trunk)

I'm a git newbie, so if i said something wrong I hope someone will correct me.

Cheers, Daniele

← back to recent threads