“git rebase <branch>” on git svn repo changed remote tracking destination?

I have a git svn repo. I have multiple release branches in here. I was preparing a new release and as part of it, I figured I’d do a “git rebase” from the previous release to pull over any changes that hadn’t been merged.

So I set up my branches…

  • Posh-Git and Posh-Hg Together?
  • Ruby 2.0.0 and git collision
  • Git - How to merge a remote branch into remote master
  • Eclipse + Maven Plugin + EGit Plugin = Checkout from GitHub a specific Branche and Tag?
  • Polymer build path prefix for github pages
  • How to checkout .git
  • git branch new_release remotes/svn-branches/new_release
    git branch old_release remotes/svn-branches/old_release

    And then I did the rebase…

    git checkout new_release
    git rebase old_release
    # watch it pull a bunch of commits
    git svn dcommit
        Committing to https://svn.mysvn.net/repo/releases/old_release ...

    After I did the “svn dcommit” I almost crapped my pants. It was hosing my old release branch in Subversion!

    Why did the remote tracking branch change as a result of doing the rebase?

    How do I fix the situation I’ve gotten myself into?

    EDIT: Okay, for getting myself out I believe I can do the following: http://svnbook.red-bean.com/en/1.5/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.undo

    Since there are only a handful of commits that were on the new_release branch that were pulled to old_release, I can revert them by hand individually on the SVN repo. I’m still confused at what happened here though.

    EDITx2: Yep, here are some steps to verify.

    1. Set up two git branches tracking remotely to SVN branches
    2. Check out one of the branches
    3. Run git svn info and observe the URL points to the correct location in SVN
    4. Run git rebase <other_branch>
    5. Run git svn info again and observe the URL changed to point to the other branch location in SVN

  • How do I use git flow with a staging environment?
  • Team Foundation Server 2013 Express - Can't connect to git repo via command line
  • TeamCity Git VCS SSH connection with Custom Private Key throws JschException: Auth fail
  • Git Config excludesfile for just a branch
  • How to make a list of all the cached files and untracked files in a git repository?
  • Converting hg bookmarks to named branches
  • One Solution collect form web for ““git rebase <branch>” on git svn repo changed remote tracking destination?”

    Looks like you’ve made a common mistake while working with git-svn.

    There’s no such thing as “tracking branches” in git-svn. It always determines URL of branch to dcommit to by first-parent history until the first commit with “git-svn-id:” signature is met. The URL near this signature is the URL where the commit will be pushed. But note, there’s a double check: the URL and revision near the signature is compared with data structures in .git/svn/refs directory and if the URL and revision contradicts them (that is true for rebased commits because rebase doesn’t touch those structures), it is not considered. So the old branch URL was the first URL of commit that wasn’t rebased.

    If you want pure Git experience, you might try SubGit as git-svn replacement. Since 2.0 it allows to create a writable pure Git mirror of your SVN repository, taking care about synchronization and concurrency. Run

    $ subgit configure --svn-url <SVNURL> project.git
    $ #adjust projectX.git/subgit/{config,authors.txt,passwd} 
    $ subgit install project.git
    $ git clone project.git project/

    After installation you may use it as a normal Git repository. So for you example you run:

    $ git checkout new_release
    $ git rebase old_release
    $ git push origin new_release
    Git Baby is a git and github fan, let's start git clone.