Post

Git Merge Ruin Svn Information

Git Merge Ruin Svn Information

I’ve successfully used git svn to fetch a project from a very old svn server.
The output of git svn info shows:

  • master points to https://svn-server/repos/myProject.
  • feature-new points to https://svn-server/repos/branches/myProject.

However, merging feature-new into master changes the mapping, causing
master to point to https://svn-server/repos/myProject/myProject/myBranch.

How can I fix this?

SVN repository:

  1. trunk: https://svn-server/repos/myProject
  2. branch: https://svn-server/repos/branches/myProject

Procedures for fetching:

1. Clone from svn

1
git svn init https://svn-server/repos --trunk=myProject --branches=branches/{myProject} myProject

2. Setting the authorsfile

1
git config svn.authorsfile ~/authors.txt
  1. Edit content of .git/config:
1
2
3
4
5
6
7
8
9
10
11
12
13
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false  
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[svn-remote "svn"]
        url = https://svn-server/repos/myProject
        fetch = myProject:refs/remotes/git-svn/trunk
        branches = branches/{myProject}/*:refs/remotes/feature-new/*
[svn]
        authorsfile = ~/authors.txt
  1. fetch
1
git svn fetch
  1. confirm the remote branches:
1
git branch -r

results:

1
2
feature-new/myProject
git-svn/trunk
  1. checkout feature-new/myProject and rename:
1
2
git checkout feature-new/myProject
git switch -c feature-new
This post is licensed under CC BY 4.0 by the author.