简体   繁体   中英

From svn to git, with a moved trunk

I'm trying to switch my svn repository to git. It's an old repository, and one of the previous maintainer moved the trunk for each new release. For example, the previous repository was at:

  • svn+ssh://svn.mycompany.com/project/release_1/trunk

Now, our current trunk is at:

  • svn+ssh://svn.mycompany.com/project/release_N/trunk

When I checkout the SVN second repository, I've the full history, including before the copy. However when I git-svn the second repository, I don't have the old history (from release_1, ...). The first commit is the copy of release_{N-1} to release_N/trunk .

Here is what I tried:

  • git svn clone --no-minimize-url --authors-file my-authors-file svn+ssh://svn.mycompany.com/project/release_N/trunk my_project.git

Since this does not work, I tried something else. Let's assume that the 'copy commit' is K, I tried:

  • git svn clone --no-minimize-url -r BASE:K --authors-file my-authors-file svn+ssh://svn.mycompany.com/project/release_N/trunk my_project.git

This time git-svn does not find any commit.

Do you know if there is a magic trick to have the full history ?

This is what I've understood by the question:
You have your history spread across several svn branches (which happen to all be called trunk). You would like all of this history when moving to git.

I think the following will fix your problem:

git svn init my_project.git

git config svn-remote.svn.url svn+ssh://svn.mycompany.com/project
git config svn-remote.svn.fetch release_N/trunk:refs/remotes/trunk
git config svn-remote.svn.branches */trunk:refs/remotes/*
git config svn.authorsfile my-authors-file

git svn fetch

This will create the release_N branch as trunk, and the remaining releases as different branches in your git repository.

As far as I know, you can't get one git svn branch to point at multiple urls, which is what I think you were trying to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM