Git-svn clone ignore-paths regex for folders

I am trying to make a git-svn clone to import all files in SVN into GIT. The command that was indicated was as follows:

git svn clone --stdlayout --ignore-paths='(/cache|/tmps|/file/conf/setting.xml)' --authors-file=../authors.txt file:///svnFolder/local-repos/PRG PRG.git 

The above clones, but the problem is that it ignores all files and the cache folder and tmps. For example, he ignores even these

 new/folder/cache meta/files/sets/tmps.html 

Can someone please help me set the regex to let ignore files and subdirectories that are in the root directory and tmps directories in ignore paths.

+6
source share
2 answers

The regex for ignore paths is too general. The provided regular expression runs in full path. For example, if your repository layout is:

 svn_root/path/to/your_project 

And then it has a standard layout of connecting lines, branches and tags, a set of test path lines that are evaluated can be:

 svn_root/path/to/your_project/trunk/new/folder/cache svn_root/path/to/your_project/trunk/meta/files/sets/tmps.html svn_root/path/to/your_project/trunk/file/conf/setting.xml svn_root/path/to/your_project/trunk/cache/... svn_root/path/to/your_project/trunk/tmps/... 

Let's start by analyzing the regular expression that you provided as part of the ignore-paths parameter:

 '(/cache|/tmps|/file/conf/setting.xml)' 
  • The surrounding parentheses mean that the expression inside must capture .
  • Pipes, or alternation , mean to evaluate each expression in the target string from several possible expressions
  • Each expression is very straightforward, but allows you to analyze each of them:
    • /cache
      • Find the letter character "/"
      • Find the letter character "c"
      • Find the letter character "a"
      • Find the letter character "c"
      • Find the letter character "h"
      • Find the letter character "e"
    • / TMPS
      • Find the letter character "/"
      • Find the letter character "t"
      • Find the letter character "m"
      • Find the letter character "p"
      • Find the letter character "s"
    • /file/conf/setting.xml
      • Find the letter character "/"
      • Find the letter character "f"
      • Find the letter character "i"
      • Find the letter character "l"
      • Find the letter character "e"
      • Find the letter character "/"
      • Find the letter character "c"
      • Find the letter character "o"
      • Find the letter character "n"
      • Find the letter character "f"
      • Find the letter character "/"
      • Find the letter character "s"
      • Find the letter character "e"
      • Find the letter character "t"
      • Find the letter character "t"
      • Find the letter character "i"
      • Find the letter character "n"
      • Find the letter character "g"
      • Match (almost) any character
      • Find the letter character "x"
      • Find the letter character "m"
      • Find the letter character "l"

Analyzing the regular expression, let's look at the paths to the examples above:

Row to evaluate:

 svn_root/path/to/your_project/trunk/new/folder/cache 
  • Scroll through each character, looking for the literal "/" and then "c", etc. until a complete match is found with your first "/ cache" subexpression. This path is ignored.

Row to evaluate:

 svn_root/path/to/your_project/trunk/meta/files/sets/tmps.html 
  • Scroll through each character, looking for the literal "/", then "c", etc. No match found.
  • Scroll through each character, looking for the literal "/" and then "t", etc. until a complete match is found with the second subexpression "/ tmps". This path is ignored.

Row to evaluate:

 svn_root/path/to/your_project/trunk/file/conf/setting.xml 
  • Scroll through each character and evaluate it with the first subexpression. No match found.
  • Scroll through each character and evaluate it in the second subexpression. No match found.
  • Scroll through each character and evaluate it against the last subexpression. Match found. This path is ignored.

From here, you can probably see why the next two are also ignored. One of the auxiliary expressions corresponds to a part of each path:

 svn_root/path/to/your_project/trunk/cache/... svn_root/path/to/your_project/trunk/tmps/... 

There are several ways to solve this problem, but if you are only trying to ignore a couple of specific directories in the body, you can change your expression as follows:

 '(trunk/cache|trunk/tmps|/file/conf/setting\.xml)' 

It really depends on what you want to do, which specific paths you want to ignore. If you need more help, if you can explain in detail how your repository is laid out and which directories should be ignored.

+11
source

How to add the addition of a marker to the beginning of the line?

  ... --ignore-paths='^(/cache|/tmps|/file/conf/setting.xml)' ... 
+1
source

All Articles