4

First of all i want to show you my project setup, I've two projects

  • Project X: Cloned from a remote svn server with git svn clone
  • Project y: Located on GitHub

Project X references Project y as git submodule:

-- Project X
  -- src/
    -- myCode1/
    -- *Project y Submodule*
    -- myCode2/
  -- .git/
  -- ...

Now I want to "push" my local done commits to the remote svn server with git svn dcommit.
Can anyone explain me the correct workflow for that project structure?


If I want to update my local git repo from the svn server I run git svn rebase and get the following:

error: The following untracked working tree files would be overwritten by checkout

Git lists all files of the submodule, but I tracked the submodule already in my local repo.
Any ideas or suggestions?

F481
  • 990
  • 8
  • 22

1 Answers1

2

From my experience git-svn doesn't work with Git submodules, mostly because of the way it sends changes to SVN: if you debug it a bit, you'll discover that it sends delta to SVN (so such pure Git concepts like submodule is not translated), then fetches just sent revision back (hence this revision doesn't contain submodules) and after all replaces just sent commit with fetched version (so the submodule will be lost in this process in the best case, though from my experience it just fails earlier). So if you can just have an untracked directory 'Project y Submodule' and manage it manually, not as submodule.

Alternatively you can try SubGit as git-svn replacement. Since 2.0 EAP it allows to create a Git mirror for a remote SVN repository.

$ subgit configure --svn-url http://svnhost/svnpath/projectX projectX.git
$ #adjust projectX.git/subgit/{config,authors.txt,passwd} and, if possible, enable rev-propchange-hook in SVN repository
$ subgit install projectX.git

After that you can clone projectX.git and work with it as with usual Git repository, the synchronization will be performed automatically. So after installation you add Project y Submodule as normal Git submodule of projectX.git.

$ git submodule add git://github.com/.../projectY.git projectY
$ git commit -m "Added projectY as submodule"
$ git push

The only thing to do is to make sure that there's no file or directory with such name in SVN, or it will overwrite the submodule.

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • Thanks for the advice, but I have to use the svn-server for project X. There is no git remote repository accessible. Like you hint subgit does not translate git submodules into svn - http://subgit.com/book/index.html#limitations – F481 Dec 20 '12 at 14:02
  • I meant creation of a Git repository on the same machine where you want to run git-svn(be it your local machine or remote)but then clone it as if it were a remote Git repository and work from the cloned repository (using push/pull, pre-receive hook will translate changes to SVN). What about submodules translation--yes, subgit doesn't translate submodules but it doesn't remove them or fail in the case of presence of a submodule(like git-svn, with git-svn you can't use git submodules at all). So you have to add a submodule manually but this change won't be reflected in SVN,that's the limitation. – Dmitry Pavlenko Dec 20 '12 at 14:47