27

在 git 1.7.9.5 中,我可以运行以下行而不会出错:

export SVNPASS=readonly
git clone git@github.com:dtenenbaum/RGalaxy.test.git
cd RGalaxy.test/
git config --add svn-remote.hedgehog.url https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/RGalaxy
git config --add svn-remote.hedgehog.fetch :refs/remotes/hedgehog
# the following is a shortcut to avoid fetching every commit since antiquity, since I happen to know the commit number
# where this folder was added to svn:
echo $SVNPASS | git svn fetch --username readonly hedgehog -r 65762:HEAD
git checkout -b local-hedgehog -t hedgehog

在 git 1.8.3.4 和 1.8.4.1 中,最后一行导致:

fatal: Cannot setup tracking information; starting point 'hedgehog' is not a branch.

这个问题的评论建议降级,但我想知道为什么会这样:这是一个错误吗?如果是这样,是否已报告?或者有没有更好的方法来做到这一点,如果是这样,它是什么?

顺便说一句,“git branch -a”返回:

* master
  remotes/hedgehog
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
4

4 回答 4

42

git-svn 开发人员不认为这是一个错误。事实上,这是 v1.8.3.2 中错误修复的结果。设置本地local-hedgehog来跟踪 git-svnhedgehog将不再有效。

从现在开始,简单地做

git checkout -b hedgehog remotes/hedgehog

足以完成所有常用的 git-svn 操作(git svn rebase、、git svn dcommit等)。

以下是 Johan Herland 的解释:

在 v1.8.3.2 之前,这仍然可以正常工作(如下所示),因为代码无法意识到遥控器无效,并回退到设置 branch.feat-bar.remote = "." (即当前的回购)。这似乎是一个不错的做法,直到您意识到“git push”回到那个无效的上游会很高兴地覆盖 refs/remotes/(mirror/)feat-bar,从而破坏 git-svn 的内部状态。

此错误已在 v1.8.3.2 中修复,更具体地说是 41c21f22(branch.c:使用 refspecs 而不是 refs/remotes/* 验证跟踪分支),您可以在该提交消息中阅读有关基本原理的更多信息。

你的最终结果是,一旦你升级到 >= v1.8.3.2,设置你的本地 feat-bar 来跟踪 git-svn 的 feat-bar 将不再被接受。设置本地feat-bar分支以在git-svn的feat-bar之上工作的正确方法是放弃上游关系并简单地执行“git checkout -b feat-bar refs/remotes/(mirror/)feat -酒吧”。

如果您想了解更多详细信息,我建议您阅读他的整个帖子

于 2013-11-07T10:18:56.577 回答
5

在 SourceTree 中,只需删除勾选“本地分支应跟踪远程分支”的复选框。

于 2015-03-06T09:32:17.737 回答
1

有许多针对此问题的建议修复:

https://github.com/nirvdrum/svn2git/issues/132
https://github.com/nirvdrum/svn2git/pull/145

在我看来,这是 svn2git 中的一个错误

于 2014-05-01T12:58:07.173 回答
0

我正在使用这个: git branch --set-upstream remotes/git-svn

于 2014-02-27T21:11:54.367 回答