2017-05-19 9 views
-2

Git-SVNを使用してSVNからgitにリポジトリを移行しようとしています。問題は、トランク内のいくつかのフォルダをマイグレーションしたいだけですが、ブランチとタグはありません。私は "git svn fetch"コマンドを使用して、最初にマイグレーションするファイルをフェッチします。私はGit-SVNを使用してSVNからgitに移行

trunk/MyProject/FolderA 
trunk/MyProject/FolderB/SubFolderB2/SubSubFolderB2Y 
trunk/MyProject/File1.txt 

を取得したいが、私は方法を考え出す苦労しています

https://svn.myexamplerepo.com/

トランク/ MyProjectと/

|-FolderA 
|-FolderB 
    |-SubFolderB1 
    |-SubFolderB2 
    |-SubSubFolderB2X 
    |-SubSubFolderB2Y 
    |-SubFolder3 
|-FolderC  
|-File1.txt 
|-File2.txt 

:私のSVNリポジトリは、このようなものですこれをする。私はgitの設定ファイルを変更しようとしました:

[core] 
    repositoryformatversion = 0 
    filemode = false 
    bare = false 
    logallrefupdates = true 
    symlinks = false 
    ignorecase = true 
[svn-remote "FolderA"] 
    url = https://svn.myexamplerepo.com/ 
    fetch = trunk/FolderA:refs/remotes/origin/FolderA 
[svn-remote "SubFolderB2Y"] 
    url = https://svn.myexamplerepo.com/ 
    fetch =trunk/FolderB/SubFolderB2/SubSubFolderB2Y:refs/remotes/origin/SubFolderB2Y 
[svn-remote "File1"] 
    url = https://svn.myexamplerepo.com/ 
    fetch = trunk/File1.txt:refs/remotes/origin/File1 
[svn] 
    authorsfile = C:/MyMigration/authors.txt 

これは動作しません。私はFile1.txtを取得するだけで、時には何もしません。何が間違っているのですか、これを行う良い方法がありますか?私は他の質問のいくつかを見てきましたが、誰もこの質問にはっきりと答えているようです。

答えて

1

変更.git/configファイルは目標を達成できません。 git svn cloneを別々に使用して、異なるフォルダ/ファイルをgitリポジトリに複製し、gitリポジトリを結合することができます。以下のように詳細手順:

1.Clone FolderA

# In a directory (such as d:\repos) 
git svn clone https://svn.myexamplerepo.com/trunk/MyProject/FolderA 
cd FolderA 
mkdir FolderA 
mv * FolderA 
git add . 
git commit -m 'move to FolderA' 

2.Clone SubSubFolderB2Y

# In a directory (such as d:\repos) 
git svn clone https://svn.myexamplerepo.com/trunk/MyProject/FolderB/SubFolderB2/SubSubFolderB2Y 
cd SubSubFolderB2Y 
mkdir SubSubFolderB2Y 
mv * SubSubFolderB2Y 
git add . 
git commit -m 'move to SubSubFolderB2Y' 

3.Clone FILE1.TXT

# In a directory (such as d:\repos) 
git svn clone https://svn.myexamplerepo.com/trunk/MyProject 
cd MyProject 
#delete all the files and folder except File1.txt 
git commit -am 'keep File1.txt' 

4.Combineすべてのgitリポジトリ一緒

# in FolderA directory (d:\repos\FolderA) 
git remote add subB d:/repos/SubSubFolderB2Y 
git remote add file d:/repos/MyProject 
git pull subB master --allow-unrelated-histories 
git pull file master --allow-unrelated-histories 

d:\repos\FolderAでGitのレポは、あなたが望むものである、それは含まれています

FolderA 
SubSubFolderB2Y 
File1.txt 
+0

のgitのsvnのinit + GitのSVNフェッチは、GitのSVNのクローンと同じです。はいgit svn cloneと--trunck = ... --branchesと--tagsを付けずにブランチやタグなしで自分のレポをクローンすることもできますが、trunck内の特定のフォルダのみのクローン作成には役立ちません。 – CPL

+0

git -svnを使いたいので、git-svnの使い方で私の答えを更新しました。試してみることができます。 –

+0

ありがとう、このメソッドは動作しますので、私はあなたに答えのクレジットを与えます。しかし、私は必要なことをやるための簡単な方法を考え出しました。 – CPL

0

私は追加することでこれを行う方法を考え出しました--include-pathsまたは--ignore-pathsです。たとえば、 - include-pathsを使用する場合:

[core] 
    repositoryformatversion = 0 
    filemode = false 
    bare = false 
    logallrefupdates = true 
    symlinks = false 
    ignorecase = true 
[svn-remote "svn"] 
    include-paths = FolderA|FolderB/SubFolderB2/SubSubFolderB2Y|File1.txt 
    url = https://svn.myexamplerepo.com/ 
    fetch = MyProject:refs/remotes/trunk 
[svn] 
    authorsfile = C:/MyMigration/authors.txt 

--ignore-pathsを使用する場合は、複製したくないパスを指定します。

だからのsvn gitのクローンを使用して複製を行うには:

git svn clone --trunk="/FolderA" --include-paths="FolderA|FolderB/SubFolderB2/SubSubFolderB2Y|File1.txt" --authors-file=authors.txt "https://svn.myexamplerepo.com/" "./MyGitFolder" 
関連する問題