Git with two remote repos, one git, one svn

So I'm using git-svn to keep in sync with our main svn repo. I also have created a remote git repo to push branches for safekeeping off of my machine until the changes are ready to be merged into svn. The problem is when I have a commit that needs to go to both svn and git, I have to git svn dcommit first. dcommit rewrites the SHAs of commits. If I've pushed, git then views the commit, rightly, as two commits as they have differing SHAs but the same content. Sometimes, I forget to svn dcommit first. How can I deal with this if I do? I need to remove the commit from the remote branch without removing it from the local repo. What I've been doing is whacking the git repo since at the moment, I'm the only one using it, but this is clearly not a satisfactory solution.

EDIT: I forgot to mention that the remote git repo is bare.


You could try fetching into the Git remote, instead of pushing to it. In other words instead of doing git push remote from the local machine (where your working copy is located), log-in to the remote machine and do git fetch local . This will always succeed. If you accidentally fetch to the remote before you do git svn dcommit , it's no problem. Just do the dcommit and then re-fetch. The fetch will always force-update any branches that need it.


  • Add pre-receive-check hook in git repo next time to avoid none dcommited information to git repo on master branch
  • clean the git repo, and push it again. or revert to the sync stage and push again

  • You may find the workflow that I describe in this article to be helpful. In particular, I believe you can utilize the same procedure described in step 3 to "back out" the commits in the remote git repo and then git push the git-svn-id-tagged commits. Your caveat about traffic on the remote git repo is of course an important one.

    I do use this procedure with a bare remote git repo.

    链接地址: http://www.djcxy.com/p/89510.html

    上一篇: git svn master来分支去掌握

    下一篇: Git有两个远程回购站,一个git,一个svn