开发者

Importing a git project into a subdirectory of a Subversion repository while maintaing history

开发者 https://www.devze.com 2023-02-08 00:10 出处:网络
Is there a preferred way to开发者_如何学Go take a git repository and import it into an existing Subversion repository as a new (arbitrarily-deeply-nested) directory while maintaining the commit histor

Is there a preferred way to开发者_如何学Go take a git repository and import it into an existing Subversion repository as a new (arbitrarily-deeply-nested) directory while maintaining the commit history?

For example, if I have a subversion repo with the following (simplified) directory structure:

backends
backends/A
backends/B

and I've been working on a new backend C in a git repo, I now want to add the contents of the git repo to the svn repo as backends/C.

Most information I've found seems to focus on importing at the top-level (generally to a newly created or otherwise empty svn repo).

My current approach is to use the following snippet from the git-filter-branch man page to push the existing top-level of the git repo down to backends/C

git filter-branch --index-filter \
        'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
                GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
                        git update-index --index-info &&
         mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD

then use git svn and git rebase to get the files into the svn repo. Is this how most people would do it, or is there a "better" way?


If you want all of the git repo to be commited into the svn subdir and dont care about the rest of the svn repo not showing up in git, you can just point git-svn at that svn subdir instead of the main dir.

Assuming the simplified directory structure you gave as an example is actually all in trunk/, then when setting up git-svn you would do something like git svn init -Ttrunk/backends/C url or git svn init --prefix=backends/C/ url. These arent exact commands so be sure to refer to the documentation but I hope this gets you started.

0

精彩评论

暂无评论...
验证码 换一张
取 消