2

Is it possible to fetch specific directories using git svn? I am trying to fetch multiple directories that match a name "XYZ" in "trunk/Path". "XYZ" is in multiple paths.

git svn init --stdlayout --no-minimize-url --trunk=trunk/Path

git svn fetch  --revision 1234:HEAD --authors-file=authors.txt --include-paths="^.*trunk\/subdirpath1/XYZ" 
git svn fetch  --revision 1234:HEAD --authors-file=authors.txt --include-paths="^.*trunk\/subdirpath2/XYZ" 
git svn fetch  --revision 1234:HEAD --authors-file=authors.txt --include-paths="^.*trunk\/subdirpath3/XYZ" 
raghzz
  • 169
  • 1
  • 3
  • 7
  • 1
    Possible duplicate of [git svn clone of a single directory of SVN repository](https://stackoverflow.com/questions/17865386/git-svn-clone-of-a-single-directory-of-svn-repository) – pRaNaY Aug 08 '17 at 15:56
  • this post does not show how to fetch multiple directories that matches a name "XYZ" in a repo. "XYZ" can be in different paths in "trunk/Path" – raghzz Aug 08 '17 at 16:05
  • It is a perl regex, so you can specify a pattern. – Vampire Aug 09 '17 at 01:30

1 Answers1

3

Yes, you can fetch specific directories. Detail steps as below:

1. Add include-paths in .git/config.

Open the .git/config file add include-paths = /path/to/specify under [svn-remote "svn"]. So the config file will look like:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[svn-remote "svn"]
    include-paths = subdirpath1/XYZ|subdirpath2/XYZ|subdirpath3/XYZ
    url = https://url/for/svn/repo
    fetch = trunk:refs/remotes/origin/trunk
    branches = branches/*:refs/remotes/origin/*
    tags = tags/*:refs/remotes/origin/tags/*

Note: paths for include-paths should contains all the path you want to fetch. Such as if there has the directory trunk/subdirpath4/XYZ, you should also add it in config file.

2. Fetch related path with --include-paths option for git svn fetch:

git svn fetch --include-paths="subdirpath1/XYZ|subdirpath2/XYZ|subdirpath3/XYZ"

Then it will fetch the related svn revisions.

Community
  • 1
  • 1
Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • If I had to update include-paths and ignore-paths, how do I do it. I tried to edit .git/config directly using vim .git/config but git svn fetch does not get the directories I am looking for – raghzz Aug 18 '17 at 16:53
  • I used only step 1 on this. For the 2 second step, I just did `git svn fetch --authors-file="c:\web\authors.txt"` (I have a authors.txt file containing all the svn authors). – Sha Apr 15 '22 at 15:10