69

I'm trying to exclude subversion's folders from being tracked by git. I tried a couple different setups for .git/info/exclude, but it doesn't seem to work. I would use git-svn, but it's a pain to request access to get that to work, so I'd rather just work around this by excluding the folders.

I want to exclude ".svn/entries"

I've tried adding the following lines to .git/info/exlude: .svn entries .svn/entries entries svn

No matter what I try, .svn entries shows up when I run git status

2
  • what do you mean its a pain to request access to get git-svn to work. git-svn just issues svn commands so if you already have SVN access you can use git-svn without anyone upstream knowing at all or needing to change anything Commented May 4, 2009 at 20:29
  • Access to install things on my work computer. There's a perl module missing, and to ask the admins to make that mod, is just a pain... Commented May 4, 2009 at 20:33

7 Answers 7

50

I think you want to use a .gitignore file in your top-level directory. This will work if you put ".svn/entries" on a line in that file. You might just put ".svn" instead of ".svn/entries" as well.

EDIT: See comments. If they files are already being tracked by git, they'll always show up in git status.

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

6 Comments

I tried this too, and this didn't work. The problem is that each folder has its own .svn/entries.
This works for me, even in the presence of one in each folder. Are the entries showing up in svn status because you've already asked git to track them? If you've git added them, they'll show up no matter what. Just git rm --cached them and you'll be OK.
There it is. I started by adding all the files in trunk... Good catch Jesse!
Not the most elegant thing in the world, but I used the following to recursively strip .svn folders (as per @JesseRusak): for dir in $(find ./ -type d); do git rm --cached -r $dir/.svn; done;
ghayes's rule is dangerous and potentially a security issue if someone has placed filenames with commands embedded in them. Or it might just fail because for example a filename has a space in it. I suggest this variant instead: find ./ -type d -name .svn -print0 | xargs -0 git rm --cached -r
|
30

This thread has the correct answer:

Git - Ignore certain files contained in specific folders

What you really need is:

.svn*

Comments

25

Put ".svn" in a ~/.gitexcludes file. Then tell git about it:

echo '.svn' > ~/.gitexcludes
git config --global core.excludesfile "/home/USER_NAME/.gitexcludes"

(Make sure you change USER_NAME so it points to your home directory)

4 Comments

Casey, I really thought that was going to work...but alas it didn't. This is pretty frustrating.
What is the difference between .gitexcludes and .gitignore?
@Shurane See stackoverflow.com/questions/10066749/git-excludes-vs-ignores -- excludes are not versioned, ignores are.
Worked. Note: it should be "~/.gitexcludes"
5

This following structure and .gitignore contents worked for me

  • \.git
  • \.svn
  • \.gitignore

.gitignore contents

.svn/
.gitignore

1 Comment

3

Do what Casey suggests, except name the file .gitignore and put it in the root of your git repo.

I also like to do a attrib +h .gitignore so it won't show up in my explorer windows.

Comments

3

if you want to keep the svn directory.

you may run the following first:

for dir in $(find ./ -type d -name \*.svn); do git rm --cached  -r $dir; done;

and then run echo ".svn" >>.gitignore in the root directory

Comments

2

since every versioned folder has a .svn directory you have to put:

*/.svn/*

3 Comments

This doesn't work. It will ignore src/.svn and coolStuff/.svn but not src/main/.svn.
for multiple folders the "*/" is the way to go! than you need two lines in .gitignore: "/.svn/" and "*/.svn/"
for subfolders exclusion use : **/.svn/

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.