Michal M
Michal M

Reputation: 9480

Have SVN function as a Second (remote) repo to push to with Git?

Can anyone tell me if it's possible to have a SVN repo as a remote (secondary) repo to push commits to? I want Git repo to be my origin repo.

I prefer Git and have my own private Git hosting and the company I work for has SVN repo. I want everything I do go to my Git repo first until I'm ready to push the all the changes to client's SVN. Let's consider I only want to push to/pull from SVN's trunk and don't need to worry about other branches/tags.

How do I go about this? I need to know:

  1. How to add an SVN repo as a remote to my Git local repo?
  2. How to pull/push changes from the remote SVN repo?

Again, I want to stress that I want to have my own private Git (hosted) repo as the origin.

Upvotes: 1

Views: 209

Answers (2)

BenC
BenC

Reputation: 8976

Yes, it is possible to have a "secondary" svn repository. I had the same problem a few weeks ago and I used several tutorials :

So basically, I did my work on my local master branch, often pushed to origin (git repository) and sometimes pushed on the svn server (company repository).

In your .git/config, you should have something like this :

[remote "origin"]
    url = your-url-to-the-git-repository
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[svn-remote "svn"]
    url = your-url-to-the-svn-repository
    fetch = :refs/remotes/git-svn

I also had a local "svn" branch but that may not be needed. In order to push my work, I had :

git push origin         # push to remote git repo
git svn dcommit         # push to remote svn repo

If you are not sure when you are pushing, use the --dry-run option :

git svn dcommit --dry-run     # check that you are pushing to the right branch

You can get more details on the usual workflow in the tutorials.

Upvotes: 2

nisc
nisc

Reputation: 4410

You can have Google Code act as a stable read-only Subversion mirror of a Git project. In this model, patches are first applied to the central Git repository and exported to Google Code later.

Instead of merely providing a link to your repository, why not widen your audience with just a handful of commands? Open up your Git-hosted project to all Subversion users, whose patches can be integrated via Git.

Of course this can also be used with non-Google Code SVN repos.

https://code.google.com/p/support/wiki/ImportingFromGit

Upvotes: 0

Related Questions