0

I have a local git repositories which initialized with

git svn init http://abc.xxx/svn/trunk/topic_A

And then I create a local branch topic_B, and want to put it under the svn URL http://abc.xxx/svn/branches/topic_B. The svn branch is created with svn client. So I don't need to create svn branch in git.

How should I modify the .git/config file to add this?

I have tried to add with:

[svn-remote "topic_B"]
url = https://abc.xxx/branches/topic_B/
fetch = :refs/remotes/topic_B

[branch "topic_B"]
remote = .
merge = refs/remotes/topic_B

However when using git from the console, git commit always choose the trunk URL as the push destination?

And in sourcetree, the GUI seems to have difficulty to fetch the newly added remote svn branch.

And it seems there is noway you can change the push destination of subversion.

Any one can figure out a correct way? Thanks a lot!

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
QZHua
  • 354
  • 2
  • 10

2 Answers2

1

You can simply rename the [svn-remote "topic_B"] to a different name so there will be no collision.

And it seems there is noway you can change the push destination of subversion.

Another option is to set it VIA command line instead of the config file:

git config --add svn-remote.topic_B.url ...
git config --add svn-remote.topic_B.fetch :refs/remotes/topic_B

This will generate the same output as you have in your question.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
0

Well, I think this is the answer, but still not the full solution I what. And I think have find out a way of doing what I actually what to :

  1. git config the svn-remote as @CodeWizard said;
  2. git svn fetch topic_B;
  3. use git branch to create new branch on your current branch ;
  4. rebase current branch onto topic_B;
  5. git svn dcommit. And this time it would be push to the correct svn URL.

This only a simple demonstration of the idea. The acctual problem is always more complicated than this. For exmaple,when topic_B is not created as an empty directory,as an SVN custom, it is often done by copying the trunk to the branches/topic_B directory. And the rebase process would be paintful.

I think this can be solved with read-tree or cherry-picking or by applying patches, e.g. if only a subdirectory or only a few files need to be changed. However I'm not very farmiliar with these comments and it would be nice if someone can give a refrence to existing solutions

QZHua
  • 354
  • 2
  • 10