5

I am converting a svn repo to a git repo and we have a number of binary files that have been checked in over the years that shouldn't have, along with images and other files, I don't really want these files present in the git repo taking up space.

I have played around with git-svn to convert the repo and have used its -ignorepaths property but I'd like to be able to feed a list into the ignore paths rather than having to specify a ignorepaths for each pattern/directory I want to exclude, if I could use a svnignore/gitignore file during the conversion that would take out this junk that would be even better.

Is there a way to do this or do I just have to bit the bullet and specify each pattern/path individually?

EDIT: updated question to be more clear as to what I was asking

2
  • It probably does but i was really just using that as an example, I'd like to have a whole heap of extensions/paths easily Commented Aug 24, 2012 at 3:56
  • I think there is no easy way out to this - you have to list what you want to ignore - either but creative regex or just list them all Commented Aug 24, 2012 at 4:00

3 Answers 3

2

Subversion is a bit complicated there if you're used to git. svn:ignore is a property that works on a per folder basis. In a particular folder, you can only ignore specific files or immediate subfolders. You can pass a file to the command that sets the ignore properties on DIRECTORY and you could also pass the .gitignore file to it with:

svn propset svn:ignore -F .gitignore DIRECTORY

But for the above mentioned reason, really practical portions in the .gitignore like */build will have no effect in Subversion.

The only thing you can do is make use of the --depth argument for svn propset for instance if you pass --depth immediates, it will set the property for DIRECTORY and every immediate subfolder. There are also ways to specify the depth or just make it inifite - I think TAB completion works there or look into the help.

There is still a major drawback though: Everytime you add a folder that contains files you want to ignore, you would have to run the svn propset command again.

Sign up to request clarification or add additional context in comments.

1 Comment

unfortunately I dont think this is what I'm looking for, I'm wanting to convert a svn repo to a git repo and take out some of the crud that was added along the way as if it never happened
1

I can confirm that git svn does not take any notice of the contents of .gitignore when fetching from Subversion, regardless of whether the .gitignore has been checked in to the repo.

The solution, as stated in your question, is to use --ignore-paths with the git svn clone. Once you've done this, it gets added to the .git/config file so you don't have to keep specifying it each time you fetch content.

Converting an existing .gitignore file into a Perl regular expression for using with --ignore-paths isn't as complicated as it might seem since you can or terms together.

For example:

/[Dd]ebug/|^rootfile\.txt$|\.bak$

excludes debug folders anywhere in the path, the specific file rootfile.txt in the root of the repo, and all *.bak files.

Tips:

  • an expression that ends with a forward slash will exclude the content of the named folder but not the folder itself
  • ^ matches the root of the repository and paths from the root don't start with a slash
  • you can use lookaround expressions in the regexes if needed, e.g. excluding all Bin folders unless they are preceded by some particular directory

Comments

0

If you want to convert svn:ignore to .gitignore or vice versa, you can use SubGit instead of git-svn, which performs this conversion automatically. The conversion command in the simplest configuration looks like:

$ subgit install path/to/svn/repository

4 Comments

Thats not really what I'm looking for, I want to create a git repository using a git-ignore to filter out files while the repo is created
gitignore has no relation to that, you question is misleading a bit. To filter files you may use "svnadmin dump" + svndumpfilter/svndumptool + "svnadmin load" or an utility by me --- svnkitfilter (you can patch it to filter whatever you want) --- to filter something at SVN side, "git filter-branch" to filter on Git side or --ignore-paths option of git-svn
yes I was looking for a way to feed git-svn a list of options for ignore-path rather than listing each individually, or something that would achieve the same thing basically
I have updated the question to try and clarify what i was looking for

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.