Command Line svn:ignore a file

This took me far too long to do, but its because no one explained it correctly to me. I’m frustrated enough that I’m not going to go back to those other websites and see if I just overlooked something. Instead I’m going to put it right here:

You don’t svn:ignore a file.

You put an svn:ignore property on the directory to ignore that filename pattern!

That makes sense, but I didn’t immediately think of that, and no source sufficiently made that point clear enough. So, if you were struggling, please grasp that concept and take a look at the commands below (which you no doubt have seen and did not think worked) and you’ll really understand what they do.

# ---------------------------------------------------------------------
#      Ignore all the .txt files in the /trunk/Blah/ directory
# ---------------------------------------------------------------------

# Go to the directory
cd trunk/Blah/              # The directory with the files

# Start editing the properties for the current directory
svn propedit svn:ignore .   # Opens an editor (SVN_EDITOR, EDITOR)

# Add the following value with a new line, save, and exit:

# See that things worked
svn propget svn:ignore .    # So you can see the properties
svn status --no-ignore      # You should see an 'I' next to the ignored files

# Commit
svn commit -m "New Ignores" # You must commit the new property change

# ---------------------------------------------------------------------
#     Ignore a single file secret.txt in the /trunk/ directory
# ---------------------------------------------------------------------

# Go to the directory
cd trunk/

# Add just the single file to the current directories ignore list (like above)
# Note the dot at the end of the command is important
svn propset svn:ignore secret.txt .

# See that things worked
svn propget svn:ignore .    # Notice the single file was added to the list
svn status --no-ignore      # You should see an 'I' next to the ignored files

# Commit
svn commit -m "Its secret"  # You must commit the new property change

That also means in GUI programs if you can’t seem to ignore a single file that is unversioned you should instead go to the directory that file is in and (like the above) add the filename to the svn:ignore list. Cheers.

UPDATE: A few commenters have mentioned this (2 John’s below!) and it is worth adding here. If the file is already under version control or shows up as ‘M’ instead of ‘I’, then you’ll first have to svn delete the file from the repository (make a backup of it somewhere first), then svn ignore the file using the steps above and copy the file back into the repository.

70 Responses


Tims Blog » Blog Archive » NULL vs False vs 0 on October 10, 2008 at 11:34 am  #

[…] svn ignore a file […]


Jan-Willem on January 20, 2009 at 12:00 pm  #

Nice clean post about this! It’s so much nicer having proper ignore patterns in your project directory


Sparky on February 7, 2009 at 8:20 pm  #

Great article, it’s good to find at last some comprehensive information on that subject. Really easy indeed. Thanks


Joseph Pecoraro on March 4, 2009 at 11:39 am  #

@Jan-Willem: @Sparky: Thanks guys. I’m glad you found this post useful.


Florian Cargoet on March 7, 2009 at 10:34 am  #

Thank you, I needed that !


Joseph Pecoraro on March 7, 2009 at 11:19 am  #

@Florian: No Problem =)


Darren on May 6, 2009 at 2:55 pm  #

I always forget how to use :ignore because I set it once per project and don’t think about it. This just replaced all my other bookmarks. Thanks.


ibar on May 9, 2009 at 2:06 pm  #

Great post. You’re right that the other HOWTOs does not explain it clearly.


Joseph Pecoraro on May 9, 2009 at 2:16 pm  #

@Darren: Thats good to hear!

@ibar: Its a shame that others aren’t very clear. It makes me question some of the other content in the “guides” if they can’t explain this concept clearly.


Life of a Plesk Admin » Ignore Files and Directories in Subversion on May 19, 2009 at 5:04 pm  #

[…] Source: […]


Tom Ilsinszki on May 21, 2009 at 10:38 am  #

Thank you! Really nice, and clean website, also really clean explanation of the svn:ignore usage. I understood in a second, what I always tried to put of learning, because it seemed complicated and never seemed to work for me.


GareCalhoun on June 4, 2009 at 8:05 am  #

Thank you for the clear explanation. Have been wondering how to do this via command line instead of various gui’s.


John Bullitt on June 24, 2009 at 4:15 pm  #

Thank you — a delightfully concise and helpful post! There’s one small “gotcha” that I’d like to point out (and which I learned the hard way). This method works only if the file “secret.txt” is not already under version control. If it is under vc, then you’ll first have to svn delete it from the repository (of course, make a backup of it somewhere first), perform the sequence of steps you describe, then OS copy it back into the the trunk directory. From then on, svn happily ignores the file.

Thanks again.


Joseph Pecoraro on June 26, 2009 at 9:34 am  #

@John: You’re absolutely right. That has gotten me in the past before! Thanks for pointing out the solution as well.


Manuel on July 2, 2009 at 12:35 am  #

You rock!

I think “ignore property” is one of the worst documented and most confusing sections in all SVN documentation… and you fixed it.



Joseph Pecoraro on July 2, 2009 at 12:57 am  #

@Manuel: De nada. Yes it always frustrated me. I’m glad I’m not the only person who had this problem and it seems like I have been able to help some people out. =)


Subversion and Ignoring a file/directory using svn:ignore « ./cmsimike on July 20, 2009 at 2:12 am  #

[…] to do to get Subversion to ignore a file or directory. I found this helpful blog entry about Command Line svn:ignore a file which got me on the right track right away. So […]


Wayne on July 23, 2009 at 1:04 am  #

Thanks man, Its 1am and this has been bugging me for half an hour. Now to get eclipse to believe it! lol

Happy coding.


Raina Gustafson on July 24, 2009 at 4:39 pm  #

You are a saint! Beautiful explanation!


kilo aka Gabor Kmetyko on October 28, 2009 at 10:09 am  #


Nice clean, explanatory. Just what I needed after at least 20 wasted minutes.


Tomek on November 8, 2009 at 8:39 am  #


thanks for this very good explanation.

There is one more issue, though. How do I un-ignore things ?



Rafalmag on November 10, 2009 at 5:42 am  #

Thx for great article!! Simple examples are the best way to understand things.
It is now in my bookmarks!

svn propedit svn:ignore .
and remove lines that you want to un-ignore


isaac on November 12, 2009 at 4:01 pm  #

This was useful, thanks.


OmegaDelta » Blog Archive » svn ignore on November 13, 2009 at 7:16 am  #

[…] how to add svn ignores from the command line […]


Mark on November 17, 2009 at 7:51 pm  #

Thanks for the post, very helpful! Not sure why this isn’t in their FAQ, especially the:
svn propedit svn:ignore .


Morten on November 19, 2009 at 5:07 am  #

As a lot of other have said: Thanks!


hajo on January 1, 2010 at 1:07 am  #

I keep forgetting this ignore-thing and remember that every time I have to struggle for a long time before it’s right. No more — this post is down-to-the-point, in a matter of seconds. Bookmarked!


Gerard on January 11, 2010 at 5:10 pm  #

Very clear and very brief. Bookmarked :)

Great post!


Brian Topping on January 13, 2010 at 2:42 pm  #

Thanks for the post, I took this to the next step. I wanted to add all files that matched a pattern (in the example here, project files created by IntelliJ IDEA). So I combined this with find and a new predicate that I just learned to come up with this:

find . -name ‘*.i[mpw][lrs]’ -execdir svn propset svn:ignore {} . \;

‘execdir’ changes directory to that folder, then makes the path argument unqualified by a directory.


Command Line svn:ignore a file « Teddy Hwang on January 23, 2010 at 12:53 pm  #

[…] Command Line svn:ignore a file → I always forget how to ignore file in SVN and hence, I’m booking marking this link. […]


Vishnu on February 11, 2010 at 6:45 am  #

Cool Info!!
I got your blog on the first click in google.


Paul Solt on March 5, 2010 at 11:02 am  #

Good call! I never fully understood how it work and you cleared it up.


juque on March 28, 2010 at 8:42 pm  #

And don’t forget to set the svn_editor variable:

export SVN_EDITOR=vi

Using vi editor.


Dawn Green on April 1, 2010 at 11:06 am  #

Thank you, Joseph! Your post is concise and perfect.


Jason H on April 21, 2010 at 12:57 pm  #

Thanks. Definitely helped clear that up for me!


Mike B on May 11, 2010 at 4:48 pm  #

Outstanding! Never seen it explained so clearly.


Nelson on May 18, 2010 at 4:18 pm  #

Thanks for the post, I forget to do the svn:ignore thing before the first commit of my project and Eclipse wasn’t helping at all on this…


Brandon on June 7, 2010 at 3:30 am  #

This is one of those things that’s SO easy in Git, and painful in Subversion. I’ve googled this before, and asked several experienced svn users, and gotten very little. So first of all: thanks for making the time I spend in svn a little less agonizing.

However, the fact that something so basic is so unclear how to do in svn suggests to me that most svn users are just getting by, by the seat of their pants. There is NO Git user who has to look this up, except for *complete* newbies. Why not switch to Git, which makes complicated things easy?

(As for me, I only use svn at work, where it is mandated.)

I’m not trying to start a flamewar over version control systems, but I have to ask: is it worth banging your head against a wall?


Joseph Pecoraro on June 8, 2010 at 3:12 am  #

@Brandon I’m a fan of Git as well, and I use it for all my personal version control as well. But, like you said, sometimes I have to work with SVN and I struggle to remember how to do basic things like this. That is kind of what motivated me to write this article originally.

Behind your question, “is it worth banging your head against a wall?”, is another more important question, “what can we learn from this?” And we can actually see by Git’s improvement in this area, that Git may have learned something from this as well. Both use “file patterns” in their ignore files, that is a developer friendly and efficient way to specify ignoring files. But the catch in SVN is that it could only be per-directory, and through magic properties. Git opened it up, no more magic. It allows per-directory files (.gitignore) and globally excluded patterns (.git/info/exclude) in easy to edit text files.

So, what did we learn? Meta-data or configuration data has to be stored somewhere. Developers know this. SVN made it unnecessarily complex to change this information. It took a very structured, generic approach, but that just got in the way. Git took a more free form approach, and it worked out very well because it is familiar to developers (dot files are common) and therefore easy to use and remember.


gwinn on July 12, 2010 at 2:02 pm  #

Thanks a lot, that’s really what i need.


alex on August 4, 2010 at 8:55 am  #



bazzany on August 5, 2010 at 4:54 am  #

Thank you for the post.
It’s helped me to undertand how to ignore file(s)


AcepStar on October 23, 2010 at 2:49 pm  #

Thanks a lot!


Barney Parker on December 4, 2010 at 3:43 pm  #

Nice! It makes me wonder why there isn’t an svn ignore command….


voidcast on March 12, 2011 at 1:17 am  #

Thanks so much for this. Finally, I understand how to use the command. Kept getting errors with the dam thing.


Hard to find svn commands « Emptiness in void on March 12, 2011 at 9:52 am  #

[…] Source Categories: Blog Tags: cheatsheet, command, svn LikeBe the first to like this post. Comments (0) Trackbacks (0) Leave a comment Trackback […]


Ryan Graff on September 3, 2011 at 3:58 pm  #

What if it still says M not I?


Campa on November 22, 2011 at 11:31 am  #

Thanks!! Clear and Useful !!

49 » Blog Archive » svn ignore a file on December 3, 2011 at 2:56 am  #

[…] post is a copy of  the original post. I just want to save a copy in case the owner deletes […]


Alfonso Mateos on December 3, 2011 at 11:02 am  #

Thanks a lot, I never understood this thing until I found your explanation.


Liviu Tudor on December 15, 2011 at 7:56 am  #

Pretty concise and to the point blog post — thanks a lot! Sorted out my svn ignore problems !


svn:ignore a file from the command line | ProgClub on January 13, 2012 at 9:26 am  #

[…] found Command Line svn:ignore a file while I was looking to do just that. This entry was posted in Chatter, Programming, SysAdmin and […]


John Doe on January 18, 2012 at 4:23 pm  #

If it still says M not I, you have to svn remove the file first and then svn ignore it.


Danny Bee on February 9, 2012 at 7:58 am  #

Every month or so when I need svn:ignore, I start looking this up again and again. I was aware of the pattern-thing but this time my to-ignore file was already under version control. So it was John Bullits comment here that ultimately solved my current problem (by un-versionizing the file first). Maybe you want to add this point to the main article because even after all those years since posting you -obviously- still get traffic on this topic.


Ahsan on June 8, 2012 at 2:06 am  #

Excellent and Succint article. It is what I was looking for.


Kushagra Gour on August 8, 2012 at 5:18 am  #

You are just awesome. Many thanks :)


Adrian Buzatu on October 3, 2012 at 10:10 am  #

Excellent post! It was annoying me so much as well, but now I found your page, applied it and it works as a charm! Thank you!


Gustavo on October 24, 2012 at 1:13 pm  #

Hi Joseph,
Good post, I have one question: If you commit the change by using svn commit -m “Its secret”… isn’t it changing the repository ? so others developers will have the same property in their workspaces when they update from the repository

If that’s the case, the objective of ignoring files should be only mark files to not consider them in my synchronizations, or updates.

I don’t test yet the commit, but I want to be sure first.
The commit represent a change, so Will the property be in the repository for all developer’s checkouts ?

I might be wrong, but correct me if I am.



binto on November 1, 2012 at 3:40 am  #

nice posting u made. But a little thing was still annoying for me, is it whether put that ignoring command on workspace or repository? many thanks


Jean on November 5, 2012 at 3:01 am  #

Thank you!


Alex on November 22, 2012 at 9:26 am  #

Thanks so much! I was wondering for years how to do this right and found nowhere such a simple and good explanation.


Daniel on November 22, 2012 at 6:04 pm  #

All I read was the quote. Enough said. Thanks :)


Jeffrey on January 8, 2013 at 11:00 am  #

Thank you so much for posting this. I finally understand!!


Aravind on April 20, 2013 at 10:28 am  #

Nice explanation. Thanks


Mark on May 23, 2013 at 5:55 pm  #

Thank you! Like Daniel said last year, the quote is what did it for me.


jstn on September 12, 2013 at 11:50 am  #

This is the first post I found that explained this in a coherent way. Thank you!


sina on September 18, 2013 at 7:33 am  #

Thank you very much for this awesome text!! it’s very usefull.


Sam on January 7, 2014 at 11:50 pm  #

Ahhhhh *sigh of relief* thank you, I was having the same issue of trying to svn ignore a file, the same way everything else *nix like works… moving along, nothing to see here.

Nonetheless this post was muchly appreciated ;)


Spade on January 21, 2014 at 5:29 pm  #

Thanks. Is there a way to set it up for multiple levels of subdirectories underneath the directory for which you are editing svn properties. For example, can I ignore all *.txt under trunk that would otherwise be found using find . -name “*.txt”?


Dave from UptimePal on April 8, 2015 at 3:24 pm  #

I was reading about other properties in subversion on Red Bean, but I like the way you explain it better.


Add a Comment