1

Here's what I would like to do. Is it possible

  • have project in git. Lots of people pushing, pulling, merging etc. Normal it workflow
  • have ONE AND ONLY ONE of those git repo's push changes in it's master branch to svn.

No one else will ever commit to the svn repo. It's one direction only. From git to svn. It will only ever take changes to master on git and add them to svn. svn is basically an svn version of a master branch.

I thought I could just do

git svn dcommit

over and over as in

..edit, push and or pull files..
git commit -a -m "foo1"
git svn dcommit
..edit, push and or pull files..
git commit -a -m "foo1"
git svn dcommit
..edit, push and or pull files..
git commit -a -m "foo1"
git svn dcommit

But that doesn't seem to work. I keep getting conflicts and messages like

$ git svn dcommit
Committing to https://my.svn.repo/svn/ ...
        M       README.md
Committed r18619
        M       README.md
r18619 = 8f00073a3f1987e97a0f0f194798b6e02e9b0345 (refs/remotes/git-svn)
No changes between current HEAD and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn
Unstaged changes after reset:
M       README.md
        M       README.md
Committed r18620
        M       README.md
r18620 = 47313477c1e38959fadd43d0001ff55210637669 (refs/remotes/git-svn)
No changes between current HEAD and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn

That seems fishy. git status gives me

# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 2 different commits each, respectively.
#

I feel like I'm fundamentally missing something. Like maybe I shouldn't be using git-svn at all. In fact if all I did was this

cd ~/git-folder
..edit files..
git commit -a -m "foo"
cd ~/svn-folder
cp -r ~/git-folder .
svn commit -m "foo"

It would actually work, I'd just lose all the commit messages and individual commits.

Can someone point out what I'm missing

gman
  • 100,619
  • 31
  • 269
  • 393

2 Answers2

2

Everything is ok. There's no relation between 'origin/master' and git-svn that uses refs/remotes/git-svn to reflect SVN state. 'master' and 'origin/master' diverged because git-svn doesn't touch 'origin/master' but replaces commits in 'master' with commits with (usually) the same content but with "git-svn-id" signature in the commit message (so sha-1 hashes are changed this way).

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • Then I'm still lost because if I try to do 'git pull; git svn dcommit' to push the latest commits from git I get errors. – gman Jul 25 '12 at 17:22
  • 1
    Maybe then SubGit would be a better solution for you. It creates a Git interface for SVN repository, so that every push to it will be automatically translated to SVN. – Dmitry Pavlenko Jul 25 '12 at 17:59
0

The output from git svn dcommit looks fine to me, it is just recreating the Git commits in the SVN repository. If you svn co the SVN repository, you would see the same commits.

I suspect that you have cloned the Git repository from somewhere else, or have pushed the repository, as indicated by the fact that you have an origin/master branch; git-svn branches are not added under an origin remote.

In other words, I don't see anything here to cause alarm. Everything appears to be working as expected.

cdhowie
  • 158,093
  • 24
  • 286
  • 300
  • Maybe I need to give more information. Assume there's 50 git repos. People are pushing and pulling etc. Now, from just one of those repos, I want to be able to pull some changes, then push to svn. Always from that one git repo and always only pushing to svn. Following the steps above, as soon as in 'git svn dcommit' that one repo now has 2 diverging commits (see message) so it's no longer in a state that can just pull from other git repos. – gman Jul 25 '12 at 05:00
  • @gman git-svn is intended to be used by *one repository* to interoperate with Subversion repositories. A repository created with git-svn is *not* intended to be shared by multiple people. – cdhowie Jul 25 '12 at 17:06
  • I'm not sharing svn with multiple people. I'm sharing git with multiple people. One and only one git, the same one every time, will interact with svn. That git will take the lastest 'master' and push it to svn. – gman Jul 26 '12 at 20:35
  • @gman Yes, the Git repositories created by git-svn are not designed to be cloned by other people, specifically because when you `git svn dcommit` the commits sent to the SVN repository need to be rewritten, and this changes history. – cdhowie Jul 26 '12 at 20:41
  • I'm not expecting anyone to clone the git-svn repo. There 3 pieces (1) a cloud of git repos (2) a single git-svn repo (3) and svn repo. I want (2) to pull from (1) the cloud and push into (3) svn continuously. That seems to be exactly what this page (http://code.google.com/p/support/wiki/ImportingFromGit) is saying is possible and yet it doesn't work for me. – gman Jul 27 '12 at 01:03
  • @gman Because git-svn rewrites Git commits after committing them to Subversion. The directions on that page look sensible for handling the rewriting of commits. The messages you provided in your question seem to indicate that everything is working as expected, so I'm not sure what problem you're having. "Doesn't work for me" is not helpful diagnostic information -- what is happening, and what did you expect to happen instead? – cdhowie Jul 29 '12 at 02:21