Warm tip: This article is reproduced from serverfault.com, please click

Git-svn failed with update-ref HEAD refs/remotes/origin/trunk: command returned error: 128

发布于 2020-12-09 14:27:27

I'm trying to do a migration of a 14.4k commit and 12 years old project from SVN to git.

As this is the tool that comes first when doing a basic browser research I tried to do it with git-svn. As it is really big I tried to do the migration from just a recent history like so :

 git svn clone -r 13800 --username=myUsername http://<URL>/collectionOfRepositories/repository1/ProjectA/ --authors-file "authors-transform.txt" --trunk trunk --tags tags --branches branches projectA-git

the svn repository looks like this :

ProjectA/
    branches/
    shelving/
    tags/
    trunk/
ProjectB/
    branches/
    shelving/
    tags/
    trunk/

I get it is quite standard and one of the recommended architecture of SVN.

When running this command I get the result :

App_Data
Checking svn:mergeinfo changes since r13800: 30 sources, 0 changed
r13800 = 9ca186bbeee33b2e3f6a5adc9d13288042afddd9 (refs/remotes/origin/aBranch                                                                                                                                                                                               )
fatal: refs/remotes/origin/trunk: not a valid SHA1
update-ref HEAD refs/remotes/origin/trunk: command returned error: 128

Notice that this happen on the first commit.

I have found this which seems to be exactly my problem. This answer has 3 suggestion, the first one is already used in my current command, the third one lead me to other issues with the subgit tool which will lead me asking another question specifically. The second suggestion proposed to use this command to fix the repo :

$ git update-ref refs/heads/master refs/remotes/git-svn
fatal: refs/remotes/git-svn: not a valid SHA1

I don't know where that "git-svn" came from so I tried to adapt it to mu case like this :

$ git branch --all
  remotes/origin/myBranch #written in red
$ git update-ref refs/heads/master refs/remotes/origin/myBranch

$ git branch --all
* master #written in green
  remotes/origin/myBranch #written in red

I have no file except the .git repository in the folder and when I do a git log there is only one commit. Also ProjectA is supposed to have around 20 branches. Was I suppose to somehow resume the command that failed ?

Another answer propose :

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

I assume my architecture is correct and that 600 revisions is quite enough so ...

ALSO : I'm on a windows environment and I ran all these command in gitbash and/or powershell. Therefore I cannot use svn-all-fast-export/svn2git @Vampire.

What am I doing wrong ?

Questioner
Amon
Viewed
0
Amon 2020-12-14 18:16:32

I didn't directly solve my problem but I think I understand why it occurred. I believe this answer (that I mentioned in the original question) was actually right about not using a revision old enough.

When I was trying to clone from a certain revision, the revision may have been old enough for the trunk, but not for all the branches and tags.

I imagine that the revision number must be old enough for all the branches and tags, otherwise, when git svn try to clone them, it doesn't find any revision and thus crashes.

I was able to solve my problem by omitting the --revision option and doing an complete migration.