6

I'm trying to sync my svn repository to git on a daily basis. After much reading, I was able to make this work by manually creating the following in my .git/config:

[svn-remote "svn"]
url = svn+ssh://svn.myserver.com/project/trunk
fetch = apps/ios/project:refs/remotes/mirror/project

I then created a branch based on this code and pushed it to the git repo with:

git checkout -b mirror/project mirror/project
git svn rebase
git push

I was very happy until I thought I'd really make sure this actually worked by deleting the cloned repo from disk and cloning it again, then trying to push some updates from svn.

git clone git@myrepo.com:myproject
git checkout mirror/project
git svn rebase

This gives me the following error: Unable to determine upstream SVN information from working tree history

I've read the myriad posts on stackoverflow about this message, but I've yet to understand any of the solutions. Is it possible to explain in terms a git newbie could understand why git has chosen to forget all about my svn config?

Tim
  • 4,560
  • 2
  • 40
  • 64
  • Does this answer your question? [Unable to determine upstream SVN information from HEAD history](https://stackoverflow.com/questions/1269566/unable-to-determine-upstream-svn-information-from-head-history) – BuZZ-dEE Jul 13 '20 at 21:56

2 Answers2

4

The following commands got my fresh clone re-connected to Subversion:

git svn init https://svn.myserver.com/project -s
git update-ref refs/remotes/origin/trunk refs/remotes/origin/master
git svn rebase

It seems that updating the refs was the missing step.

Kevin Kuszyk
  • 1,958
  • 24
  • 37
3

I don't see how a simple "git clone" could know about your svn upstream repo information.

You have stored the svn-remote in your .git/config. And that local config is not cloned when you are cloning a repo (as I mention in "Is it possible to clone git config from remote location?").

Unless you do a git svn clone or put again that svn-remote information in your repo, you won't have access to your initial information.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Ok, that just seems weird to me, but that's one mystery solved. How would I fix my local clone such that `git svn rebase` will work again? – Tim Nov 19 '13 at 07:34
  • @Tim if your local config as the `svn-remote` info (and use the right git version: http://stackoverflow.com/a/3445081/6309), then don't forget that a `git svn rebase` needs a `git svn fetch` first: http://stackoverflow.com/a/18563677/6309 – VonC Nov 19 '13 at 07:47
  • thanks got it working. I didn't realize that I had to create a local branch from the svn fetch and then push that "over" my existing remote svn branch. I'm somewhat surprised that it just worked, but I guess some merge magic happened in the background. – Tim Nov 19 '13 at 18:26