chiahao
chiahao

Reputation: 166

Git merge disrupts `git svn info` metadata

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

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

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

2. Setting the authorsfile

git config svn.authorsfile ~/authors.txt
  1. Edit content of .git/config:
[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
git svn fetch
  1. confirm the remote branches:
git branch -r

results:

feature-new/myProject
git-svn/trunk
  1. checkout feature-new/myProject and rename:
git checkout feature-new/myProject
git switch -c feature-new

Upvotes: 2

Views: 107

Answers (1)

ti7
ti7

Reputation: 18930

I can't really recommend this, but then I can't really recommend using an ancient SVN repository either!

Make the entire branch diff a patch and apply it

git svn fetch
git checkout feature
git diff master > ../feature.patch
git checkout -  # back to master
git apply ../feature.patch

I don't have a test instance, but you can make what happened a little more obvious by embedding the git log into the commit message, which has a fairly high limit Maximum length for SVN comment


Finally, though it may not be feasible for your case, converting the project to git or mercurial may be the best move for sustainability

Upvotes: 0

Related Questions