Submitting a branch from a Git repository to an SVN repository


Is it possible to push a branch to a remote SVN repository from a local Git repository?

I am currently working with a git repository in several branches.

$ git remote -v
origin (fetch)
origin (push)

$ git branch -a
* develop

There was a need to send a specific branch, for example, develop to SVN.

Searching the net for an answer offers a ton of insight into importing and cloning from SVN to Git, not the other way around.

Perhaps I'm used to the Git logic of work, but can I just add the SVN turnip as a remote repository and push the branch there?

Please tell me how to proceed


The solution is as follows (git version> 2.3.0 is required). We clone the repository, if you do not have a local copy yet, and continue working with it.

Add a remote svn repository by editing the .git/config file, add an entry to the file

[svn-remote "svn"]
  url =
  fetch = :refs/remotes/trunk

Pulling changes from the svn repository by the latest revision

git svn fetch svn -r HEAD

The output of the git branch -a command should look like this

remotes/origin/HEAD -> origin/master

Create a local branch that will be linked to the svn repository branch and go to it

git checkout -b release remotes/trunk

With the resulting branch, you can perform various operations, for example, merge with the master branch

git merge develop --allow-unrelated-histories

The resulting changes can be poured back into the svn repository (we continue on the branch that is linked to the svn repository)

git svn dcommit

The given commands allowed, in my case, to solve the problem of synchronizing git-svn and combining the result of the work of two commands of programmers

Scroll to Top