Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
826 views
in Technique[技术] by (71.8m points)

git svn - git-svn: Cannot setup tracking information; starting point is not a branch

In git 1.7.9.5 I could run the following lines without error:

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

In git 1.8.3.4 and 1.8.4.1 that last line results in:

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

The comments to this question suggest downgrading, but I'd like to know why this is happening: is it a bug? And if so, has it been reported? Or is there a better way to do this and if so, what is it?

Incidentally, "git branch -a" returns:

* master
  remotes/hedgehog
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is not considered as a bug by git-svn developpers. As a matter of fact, this is a result of a bug fix in v1.8.3.2. Setting up your local local-hedgehog to track git-svn's hedgehog will no longer work.

From now on, simply doing

git checkout -b hedgehog remotes/hedgehog

is enough to be able to do all your usual git-svn operations (git svn rebase, git svn dcommit, etc.).

Here is the explanation by Johan Herland:

Prior to v1.8.3.2 this still sort-of works (as you observe below), because the code fails to realize the remote is invalid, and falls back to setting branch.feat-bar.remote = "." (i.e. the current repo). This might seem like an ok practice until you realize that a "git push" back to that invalid upstream would happily overwrite refs/remotes/(mirror/)feat-bar, and thus break git-svn's internal state.

This bug was fixed in v1.8.3.2, more specifically 41c21f22 (branch.c: Validate tracking branches with refspecs instead of refs/remotes/*), and you can read more about the rationale in that commit message.

The end result for you is that setting up your local feat-bar to track git-svn's feat-bar will no longer be accepted once you upgrade to >= v1.8.3.2. The correct way to set up a local feat-bar branch to work on top of git-svn's feat-bar is instead to forgo the upstream relationship and simply do "git checkout -b feat-bar refs/remotes/(mirror/)feat-bar".

If you want more details, I suggest reading his whole post.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...