Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

version control - git-svn: how do I create a new svn branch via git?

I have a git repository which tracks an svn repository. I cloned it using --stdlayout.

I created a new local branch via git checkout -b foobar

Now I want this branch to end up in …/branches/foobar in the svn repository.

How do I go about that?

(snipped lots of investigative text. see question history if you care)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I know this question has been answered a while ago, but after reading it, I it might help adding examples of the specific git svn branch command and relate it to a typical workflow.

Like kch answered, use git svn branch. Here is a full example, (note the -n for dry-run to test):

git svn branch -n  -m "Branch for authentication bug" auth_bug

If this goes well, server replies with answer like this:

Copying https://scm-server.com/svn/portal/trunk at r8914 to https://scm-server.com/svn/portal/branches/auth_bug...

And without the -n switch the server probably adds something like:

Found possible branch point: https://scm-server.com/svn/portal/trunk => https://scm-server.com/portal/branches/auth_bug, 8914

Found branch parent: (refs/remotes/auth_bug)

d731b1fa028d30d685fe260f5bb912cbf59e1971

Following parent with do_switch

Successfully followed parent r8915 = 6ed10c57afcec62e9077fbeed74a326eaa4863b8

(refs/remotes/auth_bug)

The best part of it, now you can create a local branch based on your remote branch like so:

git checkout -b local/auth_bug auth_bug

Which means "check out and create local branch named auth_bug and make it follow the remote branch (last parameter) auth_bug

Test that your local branch works on that remote branch by using dcommit with --dry-run (-n):

git svn dcommit -n

And SVN server should reply with the new branch name:

Committing to https://scm-server.com/svn/portal/branches/auth_bug ...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...