2014-10-01 154 views
0

我想使用Atlassian教程(https://www.atlassian.com/git/tutorials/migrating-overview)將我的svn存儲庫遷移到git存儲庫,並且我無法正確檢出我的svn存儲庫。克隆後,使用git log時,它具有所有歷史記錄,但我沒有看到任何文件。我嘗試使用git checkout -b trunk remotes/trunk簽出其中一個遠程分支,但在新創建的分支中繼上仍然沒有文件。git svn克隆忽略文件

遷移腳本開始看起來像這樣:

#!/bin/sh 
#$1 - remote svn repo 
#$2 - local git repo name 
java -jar svn-migration-scripts.jar authors $1 > authors.txt 
git svn clone --stdlayout --authors-file=authors.txt $1 $2 

我已經想通了

我可以用git svn的命令沒有得到歷史文件的保持:

git svn clone -rHEAD $1 $2 

使用此命令簽出的文件將具有類似svn的結構(trunk,branches),所以t帽子不是我要找的東西。

另一種嘗試...

我使用svn2git從GitHub試過了,但它的使用相同的機制,所以它也失敗...命令:

svn2git https://svn/xxx --trunk trunk/src --branches branches --notags --authors ../authors.txt 

輸出:

Checked out HEAD: 
https://svn/xxxx r149793 

還沒有文件,只有.git文件夾。我試着取,拉等

另一個有趣的觀察

我發現一個奇怪的倉庫。有文件夾結構是這樣的:

* branches 
    * as usual... 
* tags 
    * as usual... 
* trunk 
    * src 
    * src 
    * pom.xml 

輸出如下:

svn2git https://svn/xxx --trunk trunk 
svn2git https://svn/xxx --trunk trunk/ 

不工作...

svn2git https://svn/xxx --trunk trunk/src 

作品。這至少很奇怪。

+0

奇怪的是,從來沒有這樣的問題。遠程回購的* trunk *用於?它是否應該包含任何文件?你可以改變分支('git checkout -b'從當前分支創建一個新的分支)。 – rlegendi 2014-10-01 11:49:13

+0

使用中繼線,它具有20MB的文件。我可以更改分支,但每個分支都是空的(儘管它的記錄是正確的)。問題可能是由svn上的路徑引起的嗎?我試過檢查出其他路徑的其他項目,它工作... – 2014-10-01 13:04:16

回答

0

我不知道究竟是什麼導致了問題,但它與我的git版本有關。我在Ubuntu上使用過git 1.9,但它失敗了,但是在OS X版本的git(1.8)上使用了相同的命令。如果你偶然發現這種問題,請嘗試使用其他版本的git。

我使用遷移腳本(svn-migration-scripts.jar是罐子Atlassian的教程下載)

#!/bin/sh 

# $1 - remote svn repo (https://svn/path/to/repository) 
# $2 - local git repo name (MyProject) 
# $3 - remote git repo address ([email protected]:/path/to/repository) 

java -jar svn-migration-scripts.jar authors $1 > authorsTmp.txt 
sed "s/mycompany\.com/youractualcompany.com/g" authorsTmp.txt > authors.txt 
git svn clone -s --authors-file authors.txt $1 $2 
cd $2 
java -Dfile.encoding=utf-8 -jar ../svn-migration-scripts.jar clean-git --force 
git remote add origin $3 
git push -u origin --all 

我希望有人會發現它有用。