![](/img/trans.png)
[英]How can I convert a Git repository with branches to a workable Mercurial repository?
[英]How can I convert a Mercurial repository to Git (with LFS support)?
我有一個 Mercurial 存儲庫,其中包含 300 個提交,其中還包含許多相對較大的(比如 10+ MiB)文件。 我想將其轉換為 Git 存儲庫,保留所有分支和合並,並使用 LFS 擴展來管理大文件。 到目前為止,這是我的過程:
hg clone <URL>
從其服務器克隆 Hg 存儲庫git init
其他地方創建一個新的 git repocd
進入 git repo,然后使用hg-fast-export -r <hg-repo> -A <authors>
。 在這一點上,我有一個工作倉庫,但所有大文件仍然是索引的一部分。 我想在“之前”插入一個新的提交來插入.gitignore
和.gitattributes
文件。git checkout --orphan new-root && git rm -rf .
git add * && git commit -m "Check in git metafiles"
git checkout master && git rebase --root --onto new-root --preserve-merges
這就是我被困的地方。 在將此錯誤轉儲給我之前,rebase 獲得了大約 10 次提交。
error: Your local changes to the following files would be overwritten by merge:
assets/ui/sayscreen/blackarrow.png
assets/ui/sayscreen/blackcircle.png
assets/ui/sayscreen/thoughtbox.png
assets/ui/sayscreen/translationbox.png
assets/ui/sayscreen/whitearrow.png
assets/ui/sayscreen/whitecircle.png
Please commit your changes or stash them before you merge.
Aborting
fatal: cherry-pick failed
Could not pick 01908b624e50709de07685ef8ab158feef02e9e0
真正讓我困惑的是,在原始 Hg 存儲庫中,此時沒有合並; 第一次合並提交是在 15。此外,運行git status
列出 50-60 個修改過的文件,即使這個特定的提交最初只涉及 8 個文件。 最后,使用git ls-files -u
嘗試查看哪些文件有沖突,但不會返回任何內容。
由於git status
列出的大多數文件都是 PNG 圖像,我的第一個想法是 LFS 以某種方式妨礙了並試圖在 rebase 期間拉出大 blob。 但是,在開始整個過程之前,我在全局上下文中運行了git lfs uninstall
,目的是在我對 rebase 操作感到滿意后執行git lfs migrate import --fixup
。
是什么導致了這些合並沖突,我該如何解決它以完成遷移?
我剛剛從最近用大文件擴展的 mercurial repo 轉換為 git。 這里有一些要點。
$hg clone <hg-repo>
$hg -v lfpull --rev "all()"
$cd ..
$hg lfconvert --to-normal <hg-repo> <hg-repo-nolf>
... // verify the repo
$hg-fast-export -r <hg-repo> -A <authors>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.