git-svn cannot create a branch to follow SVN branching

I’m struggling with the following issue. When I continue fetching revisions from SVN with

git svn fetch

I’m getting the following error:

  • How can I change my git timezone offset?
  • Sunspot Solr Gem & .gitignore
  • When using git submodule update how can you tell it to clone the dependencies with HTTP instead of GIT?
  • How to download files from git repository?
  • Git synchronize between two remotes
  • How to see the changes between two commits without commits in-between?
  • Found possible branch point: https://somecompany.com/product/trunk
    => https://somecompany.com/product/branches/deep/branches/product-001, 72666 
    Found branch parent: (refs/remotes/deep/branches/product-001) b685b7b92813885fdf 6b8e2663daf884bf504b14
    Following parent with do_switch 
    Successfully followed parent 
    error: 'refs/remotes/deep' exists; cannot create 'refs/remotes/deep/branches/product-001'
    fatal: Cannot lock the ref 'refs/remotes/deep/branches/product-001'.
    update-ref -m r72667 refs/remotes/deep/branches/product-001 df51920e8f0a53f26507 c2679eb6a9dbad91e0d6: command returned error: 128
    

    This happened because I was fetching revisions using the default filter for SVN branches:

    [svn-remote "svn"]
        url = https://somecompany.com/someproduct
        fetch = trunk:refs/remotes/trunk
        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*
    

    Now, I have the line below added, but it’s too late:

    branches = branches/deep/branches/*:refs/remotes/deep/branches/*
    

    I have tried to fix this by using git svn reset to remove all the commits. Actually I can see from the error message that git is trying right thing, but cannot because of the branch remotes/deep being existing.

    I have tried to search for 2 possible solutions:
    1. Remove that branch (remotes/deep), but as it is tracked by git as a remote, I was not able to find any solution for that.
    2. Remove the whole history related to that branch. No success too 🙁

    Does anybody know how to deal with my issue?

  • Creating SSH keys for Gerrit and Hudson
  • npm installed pre-push hook linked to a custom script is always skipped
  • GIT checking out code from output of “git describe”
  • Git log --graph; HEAD to top
  • Git bash always says the branch is ((unknown)) in all directories
  • How do you make a patch showing the difference between the branch before the first commit and the last committed version in the same branch?
  • 2 Solutions collect form web for “git-svn cannot create a branch to follow SVN branching”

    I’ve been finally able to fix the issue by performing the following 2 steps:

    1. Removing refs/remotes/deep from packed-refs
    2. Removing .git/logs/refs/remotes/deep

    But still have the issue with fetching. I need to use

    branches = branches/*:refs/remotes/*
    

    for normal branches and

    branches = branches/deep/branches/*:refs/remotes/deep/branches/*
    

    for deep branches. Unfortunately the former specification includes the later, so I’m getting the error “fatal: Cannot lock the ref ‘refs/remotes/deep'” as git-svn tries to create deep branch according to the first spec.

    So far, I do that by manually commenting the first “branches” and fetching specific revisions with deep branches, but this is not a good options as there are too many revisions to fetch for both cases.

    UPD: I have found the simple but not elegant solution for the remaining issue. I’m using branches to specify paths to deep branches and fetch to specify every branch of the first level.

    I had a very similar problem, and found that “git svn reset”, not “git reset” fixed it. If you don’t update your branches configuration beforehand, once you retrieve a commit that passes a branch point, you have to back up to retrieve them again. Otherwise they are dangling with no parent.

    So, update your branches as before, then run

    git svn reset -r<revisionnum>
    

    and follow with your git svn fetch as normal. This saved me many hours of rebuilding the entire thing from SVN.

    In your case you probably also need to investigate the “ignore” features to not trace down your embedded branch.

    Git Baby is a git and github fan, let's start git clone.