Try to search your question here, if you can't find : Ask Any Question Now ?

How can I convert a Mercurial repository to Git (with LFS support)?

HomeCategory: stackoverflowHow can I convert a Mercurial repository to Git (with LFS support)?
Avatarpragati asked 5 months ago

I have a Mercurial repo with 300-some commits in it that also contains a number of relatively large (say 10+ MiB) files. I’d like to convert this to a Git repository, keep all of the branches and merges, and also use the LFS extension to manage the big files. Here’s my process thus far:

  1. Clone the Hg repo from its server using hg clone <URL>
  2. Create a new git repo somewhere else with git init
  3. cd into the git repo, then convert with hg-fast-export -r <hg-repo> -A <authors>. At this point, I have a working repo, but all the big files are still part of the index. I want to wedge a new commit in “before” anything else to insert .gitignore and .gitattributes files.
  4. Make a new, empty branch with no parent commit: git checkout --orphan new-root && git rm -rf .
  5. Create the two files and commit them to the new branch. git add * && git commit -m "Check in git metafiles"
  6. Now my “new” root commit is ready to go, so I try to uproot the whole thing: git checkout master && git rebase --root --onto new-root --preserve-merges

And this is where I’m stuck. The rebase gets about 10 commits in before dumping this error on me.

error: Your local changes to the following files would be overwritten by merge:
Please commit your changes or stash them before you merge.
fatal: cherry-pick failed
Could not pick 01908b624e50709de07685ef8ab158feef02e9e0

What’s really confusing me here is that, in the original Hg repository, there is no merge at this point; the first merge commit is at 15. In addition, running git status lists 50-60 modified files, even though this particular commit only touched 8 files originally. Finally, using git ls-files -u to try and see what files are conflicted returns nothing.

Since most of the files listed by git status are PNG images, my first thought was that LFS was somehow getting in the way and trying to pull out the large blobs during the rebase. However, I ran git lfs uninstall in a global context before starting this whole process, with the intent of doing git lfs migrate import --fixup after I was satisfied with the rebase operation.

What’s causing these merge conflicts, and how can I get around it to finish the migration?

1 Answers
Best Answer
AvatarMatthias answered 5 months ago
Your Answer

15 + 13 =

Popular Tags

WP Facebook Auto Publish Powered By :