git svn clone of a single directory of SVN repository

I am attempting to use git svn to clone a single directory of a SVN repository into a Git repository.

If I use git svn clone svn+ssh://path/to/repo/trunk/directory, I get a Git repo without branches that mirror the branches in the source SVN repo.

  • What should I do if I put MS Office (e.g. .docx) or OpenOffice( e.g. .odt) document into a git repository?
  • Merging one change to multiple branches in Git
  • When was a file added to a branch in Git?
  • I can't uninstall Git
  • Is there a git command that returns the current project name?
  • How to set default remote ref in TortoiseGit?
  • If I use git svn --stdlayout svn+ssh://path/to/repo/trunk/directory, I get an empty Git repo. The following is the output of the command:

    Initialized empty Git repository in /directory/.git/
    Using higher level of URL: svn+ssh://path/to/repo/trunk/directory => svn+ssh://path/to/repo
    W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: File not found: revision 100, path '/trunk/directory'
    W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
    This may take a while on large repositories
    

    I had read that the way to fix the above was to add a revision range like -r 1000:HEAD, this still produces an empty repo. The output is:

    Initialized empty Git repository in /directory/.git/
    Using higher level of URL: svn+ssh://path/to/repo/trunk/directory => svn+ssh://path/to/repo
    

    Any ideas on how to clone a subdirectory of an SVN repository using git-svn that still grabs all of the branches & tags from the source SVN respository?

  • Git - Ignoring a specific modification to a config file
  • GitLab rename branch and start over on another
  • Building a particular revision in Jenkins Pipeline
  • how to resolve this ERROR running one or more of the platform when i am runnning “ionic run android --device”
  • how to create a new git repository from an existing one
  • Git ignore all except subfolder
  • 2 Solutions collect form web for “git svn clone of a single directory of SVN repository”

    You don’t want standard layout, you want something like this:

    git svn clone svn+ssh://path/to/repo/ --trunk=trunk/directory --branches=branches/*/directory --tags=tags/*/directory
    

    Prepare and enter the local project directory:

    mkdir local/project/path
    cd local/project/path
    

    Initialize the local git repository with svn remote and fetch the data:

    git svn init http://my_svn_server.com/repository/project/location
    git svn fetch
    

    Credit goes to Gabriel Saldaña: http://blog.gabrielsaldana.org/using-git-with-subversion-repository-subdirectory/

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