簡體   English   中英

如何將平面svn repo遷移到git repo

[英]How do I migrate a flat svn repo to git repo

我有一個平坦的svn存儲庫,看起來像:

my_repo/
├── file1.c
├── file2.c
├── file3.c
└── README

這個repo沒有分支或標簽,我想要做的就是將它轉換為git存儲庫並維護提交歷史記錄。

我試過了:

git svn clone --trunk=/ -A users.txt svn+ssh://user@svn.example.com/projects/my_repo dest_dir

然而,當我導航到dest_dir並執行git svn fetch ,我認為它可以工作,它似乎不會取任何東西。 使用git log產生:

fatal: bad default revision 'HEAD'

如果我使用svn checkout svn+ssh://user@svn.example.com/projects/my_repo它會返回:

A    my_repo/file1.c
A    my_repo/file2.c
A    my_repo/file3.c
A    my_repo/README
Checked out revision 57.

因此存儲庫是活的並且可訪問。

我嘗試了各種工具,包括subgit ,它給了我這個錯誤: svn: E170003: 'stat' not implemented ,我認為這是因為托管存儲庫的服務器使用舊版本的subversion。 無法控制服務器,因此無法執行更新。

我也嘗試使用svn2git ,使用該命令

svn2git svn+ssh://user@svn.example.com/projects/my_repo --rootistrunk -authors users.txt --verbose

但這給了我另一個錯誤:

E: 'svn+ssh:/user@svn.example.com/projects/my_repo' is not a complete URL and a separate URL is not specified command failed

這讓我很難過,我不知道為什么它不起作用。 基本上我想知道如何在保持歷史的同時將我的svn repo變成一個git repo。 希望有人可以幫助我,或指出我正確的方向。 從來沒有意識到將這個簡單的回購轉移到git會很困難!

謝謝

問題在於svn2git--rootistrunk參數。 而不是那樣,試試這個:

svn2git svn+ssh://user@svn.example.com/projects/my_repo --trunk / --notags --nobranches --authors users.txt --verbose

我有同樣的問題。 不是標准的svn存儲庫:沒有主干,沒有標簽,沒有早午餐。 我檢查了svn2git的所有可能選項,但沒有成功。 因為svn2git只是git svn的ruby包裝器,所以我直接嘗試了git svn並且沒關系。 這就是我所做的。

初始化空git dir並給出svn存儲庫路徑以及trunk,tags和brunches的相對路徑。 在我的情況下它是/因為我沒有任何這些。

1. git svn init http://svnmydomain.com/urlpart/projectname --trunk=/ --tags=/ --branches=/

如果svn repo受密碼保護,你將不得不為上面的命令提供用戶名和密碼參數,但在大多數情況下它不會起作用,因為它有點兒麻煩。 而是在當前文件夾中svn checkout。 git svn將使用svn現金,不會要求您輸入密碼。

檢查git config是否正常。 類型

2. git config --list

你應該看到這個:

svn-remote.svn.url=http://svnmydomain.com/urlpart    
svn-remote.svn.fetch=urlpart/projectname:refs/remotes/origin/trunk
svn-remote.svn.branches=urlpart/projectname/*:refs/remotes/origin/*
svn-remote.svn.tags=urlpart/projectname/*:refs/remotes/origin/tags/*

如果git config不正確,請通過執行手動修復它

git config <key> <value>

現在當git config正常時你應該從svn獲取數據並將其推送到git服務器

3. git svn fetch
4. git remote add origin git@gitdomain:url/gitproject.git
5. git add .
6. git commit -m "merge from svn"
7. git push origin master

如果有些人繼續在svn中工作,你需要不斷地與git同步svn。 要這樣做:

8. git svn rebase
9. git push origin master 

使用git v2.20.1進行了一次舊的“扁平”SVN回購同樣的問題:(關於http://www.sailmaker.co.uk/blog/2013/05/05/migrating-from-svn-上的食譜to-git-preserving-branches-and-tags-3 /

git svn init <SVN https URL> --stdlayout --prefix=svn/ -T /
git svn fetch --all

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM