2

As mentioned in this question (and in the Git FAQ), you can't store empty directories in Git.

I have a git-svn clone, and I want to use Git in it to work against my project's Subversion repository.

The problem is that there are some empty directories that are stored under Subversion and are necessary for compiling the project.

So far, I've been doing what was suggested in the FAQ: I added a .gitignore file in each directory that should stay empty, and committed that addition to Git, so whenever I clone from this git-svn repository, I get all the empty directories and I can compile.

The minor trouble is that whenever I want to git svn dcommit back to the Subversion repository, I need to do that from a separate Git branch without the commit in which all the .gitignore files were added, so that they don't get added to Subversion as well.

But I thought about it, and it might not be that bad - so my questions is, is there any reason why I should not commit the addition of the .gitignore files for each empty directory to Subversion?

Community
  • 1
  • 1
Daniel Hershcovich
  • 3,751
  • 2
  • 30
  • 35

2 Answers2

1

Since no one else has added the answer "No" yet, I'll add one :) That should be fine - Subversion doesn't treat files called .gitignore in any special way.

Mark Longair
  • 446,582
  • 72
  • 411
  • 327
  • I like this answer. I didn't think Subversion treats .gitignore files in a special way, but it does seem like there should be a better way. And the other way suggested here (not doing anything) seems to be just as good (apart from pure Git clones) - it's just the difference between a global .gitignore file and a .gitignore file per empty directory. – Daniel Hershcovich Apr 08 '11 at 20:26
1

I don't understand why you have to do anything. When you git svn clone it creates the empty directories for you, and unless you want to add or remove empty directories, you can just use git as normal. The only time it would be a problem is if you want to make a pure git clone of your git svn clone. Since git has local branches, that's usually not necessary, but if it were necessary for some reason, I think the easiest thing would be to make your "clone" by doing a regular file-system copy.

Tyler
  • 21,762
  • 11
  • 61
  • 90
  • I think that's what I'm going to do - have the other team just make a regular file-system copy from my `git svn` clone. I might add the .gitignore files to Subversion anyway though, because I do want things in these directories to be ignored, and this way doesn't seem much worse than a single high-level `.gitignore` file. – Daniel Hershcovich Apr 09 '11 at 14:08