1

I've got a git repository cloned from an external SVN repository through git svn clone. On a separate machine, I'd like to get this clone set up again, so I can update the git repository with recent SVN changes. How do I do this?

It seems using git svn clone or git svn init creates an empty repository, and git svn fetch uses a predefined URL. I don't want to have to reset my Git repository - I just want to pull the existing remote, re-link it to the same SVN, and continue with the git svn rebase to update Git with recent SVN changes.

jevon
  • 3,197
  • 3
  • 32
  • 40

3 Answers3

1

If my svn repo did not follow standard layout this is what worked for me was:

git clone <git-repo>
cd <git-repo>
git svn init <svn-repo>
git config svn.authorsfile <your-authors-file>.txt
git svn fetch
(Optional) git branch -a  (should see a remotes/git-svn branch)
git checkout -b <some-branch-name> git-svn 
git checkout master
git rebase <some-branch-name>
#Now you can use "git svn rebase" etc.
git rebase origin/master
# Now you can push and pull

If my svn repo did follow the standard layout jevon's answer worked.

Ying-Shan Lin
  • 607
  • 5
  • 22
Stormholt
  • 13
  • 6
0

Why not copy your local repo files to the second machine.

$ scp /path/to/first/repo user@second_machine_host:/path/to/second/repo

or

$ rsync -avz /path/to/first/repo user@second_machine_host:/path/to/second/repo

or if you use Windows, you can just copy repo directory to the second machine by Remote Desktop, see here.

Community
  • 1
  • 1
oldman
  • 4,286
  • 2
  • 20
  • 15
  • That's the obvious option, but I don't have access from the first machine. I want to re-establish the previously cloned repository from scratch. – jevon Mar 23 '14 at 21:27
0

You can re-establish a git svn clone just by running the same commands you used to initialise the remote Git in the first place (but you might need to ensure you use the same --prefix in the git svn clone). It looks like Git keeps track of SVN metadata in the Git commit messages (git-svn-id:) to prevent duplicates.

That is:

  1. git svn clone -s https://openclerk.googlecode.com/svn/ openclerk -A svn-authors.txt --prefix "" (the empty prefix is because the original Git repository used an empty prefix too)
  2. git remote add origin https://github.com/soundasleep/openclerk.git
  3. git branch --set-upstream-to=origin/master master
  4. git pull
  5. Carry on with git push, git svn rebase, git svn dcommit as necessary
jevon
  • 3,197
  • 3
  • 32
  • 40