Skip to contentSkip to conversation

git-svn branch naming question

DISCUSSION Miklos Vajna 5 participants 13 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

hi,

i'm using git-svn for projects where i don't just want to commit to trunk but to other branches, too.

for example:

git-svn clone -s svn+ssh://[email protected]/svn/ooo-build ooo-build

then i have a local 'master' branch and all the other branches are local branches.

so, when i want to work in the ooo-build-2-3 branch, i do a:

git checkout -b ooo-build-2-3 ooo-build-2-3

but when i do a git svn rebase, i get:

warning: refname 'ooo-build-2-3' is ambiguous.

what am i doing wrong?

in fact i suspect that in case i would use some other branch name, like simply '2-3' then i could get rid of this warning, but that's the problem with using the equivalent name of the remote branch when working in a branch locally?

probably i miss some parameter to git-svn clone so that it would prefix the refs with some 'origin'?

thanks,
- VMiklos

#1 lore raw
Quoted 14 lines · Miklos Vajna

hi,

i'm using git-svn for projects where i don't just want to commit to trunk but to other branches, too.

for example:

git-svn clone -s svn+ssh://[email protected]/svn/ooo-build ooo-build

then i have a local 'master' branch and all the other branches are local branches.

so, when i want to work in the ooo-build-2-3 branch, i do a:

Quoted 7 lines

git checkout -b ooo-build-2-3 ooo-build-2-3

but when i do a git svn rebase, i get:

warning: refname 'ooo-build-2-3' is ambiguous.

what am i doing wrong?

Try using 'git svn rebase remotes/ooo-build-2-3'.

git-svn should produce its branches under refs/remotes/* and your local branches are under refs/heads/*.

By using 'git checkout -b ooo-build-2-3 ooo-build-2-3' you created refs/heads/ooo-build-2-3 as a copy of refs/remotes/ooo-build-2-3 and now using only ooo-build-2-3 is ambigious. (at least in some cases where git won't take refs/heads/ooo-build-2-3)

Quoted 6 lines

in fact i suspect that in case i would use some other branch name, like simply '2-3' then i could get rid of this warning, but that's the problem with using the equivalent name of the remote branch when working in a branch locally?

See above.

Quoted 2 lines

probably i miss some parameter to git-svn clone so that it would prefix the refs with some 'origin'?

Look up --prefix in the manpage for git-svn.

-Peter

#2 lore raw
Quoted 1 line · Peter Baumann

Look up --prefix in the manpage for git-svn.

great, --prefix is what i missed.

a related question: is it possible to avoid even the "remotes" prefix?

it could be useful when creating an incremental import of an svn repo. (ie when using git-svn as a replacement of git-svnimport.)

so after the clone, one will see all the svn branches as a remote branch, since they will be local (and not remote) ones in the mirror repo.

thanks,
- VMiklos

#3 lore raw
Quoted 10 lines · Miklos Vajna
Quoted 1 line · Peter Baumann

Look up --prefix in the manpage for git-svn.

great, --prefix is what i missed.

a related question: is it possible to avoid even the "remotes" prefix?

it could be useful when creating an incremental import of an svn repo. (ie when using git-svn as a replacement of git-svnimport.)

git svn init --stdlayout creates this entry in your .git/config per default

[svn-remote "svn"]
url = https://url/to/your/svn/repo
fetch = trunk:refs/remotes/trunk
branches = branches/*:refs/remotes/*
tags = tags/*:refs/remotes/tags/*

You could change this to

[svn-remote "svn"]
url = https://url/to/your/svn/repo
fetch = trunk:refs/remotes/origin/trunk branches = branches/*:refs/remotes/origin/* tags = tags/*:refs/remotes/origin/tags/*

to get what --prefix origin would do.

On the other hand you could forget completly the remote part by specifying

[svn-remote "svn"]
url = https://url/to/your/svn/repo
fetch = trunk:refs/heads/trunk
branches = branches/*:refs/heads/*
tags = tags/*:refs/heads/tags/*

but I advice you to not do this. refs/remotes has a special meaning in git, e.g. you can't commit directly to it (which makes sense, because it only tracks the state of the remote repo. On the other hand remote branches won't get cloned per default.)

Side note, if you want to track only some branches, or if you have a strange svn layout, you could use something like this:

[svn-remote "svn"]
url = https://url/to/your/svn/repo
fetch = trunk:refs/remotes/origin/trunk fetch = branches/branchA:refs/remotes/origin/branchA fetch = branches/branchB:refs/remotes/origin/branchB
...

-Peter

#4 lore raw
Quoted 8 lines · Peter Baumann

On the other hand you could forget completly the remote part by specifying

[svn-remote "svn"]
url = https://url/to/your/svn/repo
fetch = trunk:refs/heads/trunk
branches = branches/*:refs/heads/*
tags = tags/*:refs/heads/tags/*

Quoted 4 lines

but I advice you to not do this. refs/remotes has a special meaning in git, e.g. you can't commit directly to it (which makes sense, because it only tracks the state of the remote repo. On the other hand remote branches won't get cloned per default.)

yes, that's exactly what i want to do - in case the target is to convert an svn repo to a git one (and i need git-svn since git-svnimport is to be removed in 1.5.4)

thanks,
- VMiklos

#5 lore raw
Quoted 6 lines · Miklos Vajna
Quoted 6 lines

[svn-remote "svn"]
url = https://url/to/your/svn/repo
fetch = trunk:refs/heads/trunk
branches = branches/*:refs/heads/*
tags = tags/*:refs/heads/tags/*

Quoted 8 lines
Quoted 4 lines

but I advice you to not do this. refs/remotes has a special meaning in git, e.g. you can't commit directly to it (which makes sense, because it only tracks the state of the remote repo. On the other hand remote branches won't get cloned per default.)

yes, that's exactly what i want to do - in case the target is to convert an svn repo to a git one (and i need git-svn since git-svnimport is to be removed in 1.5.4)

hm, this seem to be not-working for me.

after "git svn init -s url" i edited the config:

$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[svn-remote "svn"]
        url = svn+ssh://[email protected]/svn/ooo-build
        fetch = trunk:refs/master
        branches = branches/*:refs/*
        tags = tags/*:refs/tags/*

and wanted to fetch the revisions, but actually

$ git svn fetch

does not fetch any revisions. (yes, it does once i put back the "remotes" prefix). is this a bug? :)

thanks,
- VMiklos

#6 lore raw
Quoted 4 lines · Miklos Vajna
Quoted 3 lines · Miklos Vajna
Quoted 3 lines

[svn-remote "svn"]
url = https://url/to/your/svn/repo
fetch = trunk:refs/heads/trunk

                                 ^^^^^
Quoted 1 line
Quoted 1 line
Quoted 1 line

branches = branches/*:refs/heads/*

                                         ^^^^^
Quoted 1 line
Quoted 1 line
Quoted 1 line
        tags = tags/*:refs/heads/tags/*
                                 ^^^^^
Quoted 4 lines

url = svn+ssh://[email protected]/svn/ooo-build fetch = trunk:refs/master
branches = branches/*:refs/*
tags = tags/*:refs/tags/*

Just a guess, but this seems pretty headless ;-)

Björn

Quoted 9 lines

and wanted to fetch the revisions, but actually

$ git svn fetch

does not fetch any revisions. (yes, it does once i put back the "remotes" prefix). is this a bug? :)

thanks,
- VMiklos

#7 lore raw
Quoted 6 lines · Björn Steinbrink
Quoted 4 lines

url = svn+ssh://[email protected]/svn/ooo-build fetch = trunk:refs/master
branches = branches/*:refs/*
tags = tags/*:refs/tags/*

Just a guess, but this seems pretty headless ;-)

oh, right. here is my fixed config:

[svn-remote "svn"]
url = svn+ssh://[email protected]/svn/ooo-build fetch = trunk:refs/heads/master
branches = branches/*:refs/heads/*
tags = tags/*:refs/tags/*

git svn fetch still does not seem to do anything :S

thanks,
- VMiklos

#8 lore raw
In reply to Miklos Vajna
Quoted 32 lines · Miklos Vajna
Quoted 6 lines · Miklos Vajna
Quoted 6 lines

[svn-remote "svn"]
url = https://url/to/your/svn/repo
fetch = trunk:refs/heads/trunk
branches = branches/*:refs/heads/*
tags = tags/*:refs/heads/tags/*

Quoted 8 lines
Quoted 4 lines

but I advice you to not do this. refs/remotes has a special meaning in git, e.g. you can't commit directly to it (which makes sense, because it only tracks the state of the remote repo. On the other hand remote branches won't get cloned per default.)

yes, that's exactly what i want to do - in case the target is to convert an svn repo to a git one (and i need git-svn since git-svnimport is to be removed in 1.5.4)

hm, this seem to be not-working for me.

after "git svn init -s url" i edited the config:

$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[svn-remote "svn"]
        url = svn+ssh://[email protected]/svn/ooo-build
        fetch = trunk:refs/master
        branches = branches/*:refs/*
        tags = tags/*:refs/tags/*
Quoted 6 lines

and wanted to fetch the revisions, but actually

$ git svn fetch

does not fetch any revisions. (yes, it does once i put back the "remotes" prefix). is this a bug? :)

I'm not sure if it's considered a "bug", but that's just the way it is at the moment. I can't remember why, but I did make git-svn force the presence of the "remotes/" prefix in all refs it writes to...

Signature · 1 line
Eric Wong
#9 lore raw
Quoted 4 lines · Eric Wong

I'm not sure if it's considered a "bug", but that's just the way it is at the moment. I can't remember why, but I did make git-svn force the presence of the "remotes/" prefix in all refs it writes to...

okay, i see. one problem: git-svnimport is to be removed and (afaik) the supposed way is to use git-svn instead. what is the supposed way to use git-svn to convert an svn repo to a git one if the method i tried is not working?

(if the branches are fetched to "remotes/" then they won't be visible when one clones the converted repo)

thanks,
- VMiklos

#10 lore raw
Quoted 6 lines · Miklos Vajna
Quoted 4 lines · Eric Wong

I'm not sure if it's considered a "bug", but that's just the way it is at the moment. I can't remember why, but I did make git-svn force the presence of the "remotes/" prefix in all refs it writes to...

Quoted 7 lines

okay, i see. one problem: git-svnimport is to be removed and (afaik) the supposed way is to use git-svn instead. what is the supposed way to use git-svn to convert an svn repo to a git one if the method i tried is not working?

(if the branches are fetched to "remotes/" then they won't be visible when one clones the converted repo)

I'm pretty sure the reasoning behind "remotes/" being forced by git-svn was to prevent users from shooting themselves in the foot, since committing to those remote refs will break both git-svn fetch and dcommit...

Heck, the entire "remotes/" idea started because a git-svn user made the mistake of committing to the remote tracking branch directly:

http://thread.gmane.org/gmane.comp.version-control.git/16869/focus=16875

I'll consider accepting a patch to lift that restriction (but still use the "remotes/" by default, of course).

Also, it's possible to fetch them after editing .git/config a little:

Harvey Harrison's "[RFC] Mirroring svn" post has a good example on how to do it.

http://mid.gmane.org/1196922153.10408.101.camel@brick

Perhaps git-clone could gain the ability to clone refs/remotes/ as-is without an extra step?

Signature · 1 line
Eric Wong
#11 lore raw
Quoted 4 lines · Eric Wong

Perhaps git-clone could gain the ability to clone refs/remotes/ as-is without an extra step?

Something in the spirit of --mirror perhaps?

--mirror-remotes sounds about right

Harvey

#12 lore raw
In reply to Eric Wong
Quoted 2 lines · Eric Wong

Perhaps git-clone could gain the ability to clone refs/remotes/ as-is without an extra step?

well, what i did for now is to use 2 repos. i use git-svn to create a regular git-svn repo from svn, then an other one to create a regular git repo from the git-svn one. this has one benefit: git-svn requires a working tree, but i definitely want to publish only a bare repo. so here is what i have in the bare repo's config:

[remote "origin"]
url = /path/to/git-svn/repo
fetch = +refs/remotes/origin/tags/*:refs/tags/* fetch = +refs/remotes/origin/trunk:refs/heads/master fetch = +refs/remotes/origin/*:refs/heads/*

then a simple git fetch will do what i need. i'm not entirely sure this is the right think to do, but works for me :)

thanks,
- VMiklos