git-svn migration fatal: not a valid SHA1 update-ref refs/heads/master refs/remotes/trunk: command returned error: 128

青春壹個敷衍的年華 提交于 2021-02-06 09:59:13

问题


Trying to migrate a large but linear svn repository to git. The svn repository does not have the standard layout (trunk, branches, tags)...just one directory with the trunk.

Ubuntu 12.4 LTS,git 1.7.9.5.

$ git svn clone https://coawstmodel.sourcerepo.com/coawstmodel/COAWST --authors-file=../users.txt COAWST

...

    D   WPS/metgrid/storage_module.F
    D   WPS/metgrid/process_domain_module.F
W: -empty_dir: WPS/metgrid/gridinfo_module.F
W: -empty_dir: WPS/metgrid/input_module.F
W: -empty_dir: WPS/metgrid/interp_option_module.F
W: -empty_dir: WPS/metgrid/module_date_pack.F
W: -empty_dir: WPS/metgrid/process_domain_module.F
W: -empty_dir: WPS/metgrid/storage_module.F
r635 = c19181c9718e701788b540ed0cc559e4fbddf413 (refs/remotes/git-svn)
    M   Tools/Docs/COAWST_User_Manual.doc
r636 = 1b7849c3e5a20856c9ddb909a5f53ddf8501ad33 (refs/remotes/git-svn)
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 14143, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (14039/14039), done.
Writing objects: 100% (14143/14143), done.
Total 14143 (delta 8350), reused 0 (delta 0)
fatal: refs/remotes/trunk: not a valid SHA1
update-ref refs/heads/master refs/remotes/trunk: command returned error: 128

I have tried variants with combinations of -s, -t Trunk, -t COAWST, --preserve-empty-dirs (which I would like to do), --no-meta-data (per Pro Git)...always the same final error.

Thanks for any suggestions!


回答1:


I think that you run the correct command. Alternatively you could run

$ git svn clone https://coawstmodel.sourcerepo.com/coawstmodel --trunk=COAWST --authors-file=../users.txt COAWST

git-svn nearly finishes its work in each case. The only thing it tries to do is to set 'master' to point to your trunk. Because of some bug it tries to set it to the wrong value but you can perform it manually with

$ git update-ref refs/heads/master refs/remotes/git-svn

If you will still have problems you may try to convert the repository with SubGit in 3 steps:

$ subgit configure path/to/svn/repository
#edit path/to/svn/repository/conf/subgit.conf to set trunk = COAWST:refs/heads/master and authorsFile = path/to/users.txt
$ subgit install path/to/svn/repository

The converted repository will be at path/to/svn/repository/conf/.git




回答2:


Every time this happened to me Git simply couldn't fetch a commit from trunk in Subversion:

fatal: refs/remotes/trunk: not a valid SHA1

Reasons:

  • You didn't specify Subversion layout when it was not standard (trunk-tags-branches). Specifically for the error - you have no /trunk.
  • You didn't fetch from revision old enough to span at least one commit into trunk (for example, using -r option).
  • Combination of the above.



回答3:


I had the same problem today.

The problem is probably that the SVN repository does not have a trunk directory. The standard trunk, tags and branches directories seems to be optional in SVN. But git-svn needs to know about this when migrating.

It is also possible that some of the directories are there but named differently. (for example trunk could be named "project" instead of "trunk", branches could be named "branches" as usual and tags could be missing. Or "trunk" could be named "Trunk".)

  • If there are none of these standard directories in the SVN repo, and everything is just placed in the root of the repo, the solution is simply to not to try clone the standard svn-directories. Just clone the root.

  • If they exists (or some of them does), but under different names, git-svn has to be told about these names.

I used Tortoise Git to migrate from SVN to GIT. In TortoiseGit, it is done by cloning from the svn repository (yep!) and checking the "From SVN Repository" checkbox.

  • If there are no trunk, tags or branches directories in the SVN repo, simply uncheck the "trunk", "tags" and "branches" checkboxes in the "From SVN Repository" section of the clone dialog.

  • If the standard directories are there, but are named differently than normal, keep them checked but write the used names in the textbox next to them.

    (From the commandline this can be done with the -T, -t and -b switches. See http://www.sailmaker.co.uk/blog/2013/05/05/migrating-from-svn-to-git-preserving-branches-and-tags-3/ under "non-standard SVN layout").

(Those were the two cases i encountered - more complex cases may exist. I had several SVN repositories with neither trunk, tags or branches directories and unchecking these 3 checkboxes made it work. I also had a case where the trunk dir was called "project" instead of "trunk", but the branches dir was named normally and there were no tags dir. Unchecking the tags checkbox and entering the name of the trunk directory made that case work.)




回答4:


Also had the issue. Figured out that git command is case-sensitive and that I was specifying --trunk=trunk/MyLib instead of --trunk=trunk.Mylib

I managed to resolve it that way.

Hope this helps someone...




回答5:


I believe I have two sets of git binaries installed on my Windows machine:

a. Git (whatever the typical Windows installation is--forgot where I got it). This one installs the "Git Bash Here" choice on the right-click file explorer context menu.

b. Tortoise Git.

I received the error when cloning a non-standard svn repository using "Git Bash" (i.e. Git).

I then tried using TortoiseGit (as suggested by one poster here), and that worked without errors.

However, TortoiseGit displays the actual command line it is using, and I became suspicious because that command line is the same as I used unsuccessfully with Git.

I then tried "Git Bash" again and provided the full path to what I believe is the TortoiseGit git binary, i.e.:

"C:/Program Files/Git/bin/git.exe" svn clone svn://localhost/dtapublic tempgitrepo

and that worked fine.

However,

git svn clone svn://localhost/dtapublic tempgitrepo

causes the error.

I believe there are possibly two git binaries in play, and that is why TortoiseGit cured the problem for one poster. The git binary shipped with "Git" does not work for non-standard svn repositories, and the git binary shipped with "TortoiseGit" does work.



来源:https://stackoverflow.com/questions/11694065/git-svn-migration-fatal-not-a-valid-sha1-update-ref-refs-heads-master-refs-remo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!