<p>I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'.</p>

<p>I have files I never want to check in to source control (like ones found in bin folder such as DLLs, code generated output, etc.) Is there a way to filter those files/folders out from appearing as "new" that might be added. They tend to clutter up the list of files that I am actually interested in.  Does P4 have the equivalent of Subversion's 'ignore file' feature? </p>

[{'answer_id': 55509, 'author': 'raven', 'author_id': 4228, 'author_profile': 'https://Stackoverflow.com/users/4228', 'pm_score': 7, 'selected': True, 'text': '<p>As of version 2012.1, Perforce supports the <code>P4IGNORE</code> environment variable. I updated my answer to <a href="https://stackoverflow.com/a/3103898/4228">this question about ignoring directories</a> with an explanation of how it works. Then I noticed this answer, which is now superfluous I guess.</p>\n\n<hr>\n\n<p>Assuming you have a client named "CLIENT", a directory named "foo" (located at your project root), and you wish to ignore all .dll files in that directory tree, you can add the following lines to your workspace view to accomplish this:</p>\n\n<pre>\n-//depot/foo/*.dll //CLIENT/foo/*.dll\n-//depot/foo/.../*.dll //CLIENT/foo/.../*.dll\n</pre>\n\n<p>The first line removes them from the directory "foo" and the second line removes them from all sub directories.  Now, when you \'Reconcile Offline Work...\', all the .dll files will be moved into "Excluded Files" folders at the bottom of the folder diff display. They will be out of your way, but can still view and manipulate them if you really need to.</p>\n\n<p>You can also do it another way, which will reduce your "Excluded Files" folder to just one, but you won\'t be able to manipulate any of the files it contains because the path will be corrupt (but if you just want them out of your way, it doesn\'t matter).</p>\n\n<pre>\n-//depot/foo.../*.dll //CLIENT/foo.../*.dll\n</pre>\n'}, {'answer_id': 56498, 'author': 'Mark', 'author_id': 4405, 'author_profile': 'https://Stackoverflow.com/users/4405', 'pm_score': 2, 'selected': False, 'text': "<p>Will's suggestion of using <code>.p4ignore</code> only seems to work with the WebSphere Studio (P4WSAD) plugin. I just tried it on my local windows box and any files and directories that I listed were <em>not</em> ignored. </p>\n\n<p>Raven's suggestion of modifying your client spec is the correct way under Perforce. Proper organization of your code/data/executables and generated output files will make the process of excluding files from being checked in much easier.</p>\n\n<p>As a more draconian approach, you can always write a submit trigger which will reject submission of change-lists if they contain a certain file or files with a certain extension, etc.  </p>\n"}, {'answer_id': 2131347, 'author': 'Deepak Sarda', 'author_id': 143438, 'author_profile': 'https://Stackoverflow.com/users/143438', 'pm_score': -1, 'selected': False, 'text': '<p>If you are using the Eclipse Perforce plugin, then <a href="http://perforce.com/perforce/doc.091/manuals/p4wsad/topics/adding.html" rel="nofollow noreferrer">the plugin documentation</a> lists several ways to ignore files.</p>\n'}, {'answer_id': 3021154, 'author': 'Mike Burrows', 'author_id': 171757, 'author_profile': 'https://Stackoverflow.com/users/171757', 'pm_score': 3, 'selected': False, 'text': '<p>If you want a solution that will apply to all work-spaces without needing to be copied around, you (or your sysadmin) can refuse submission of those file-types through using lines like the below in the p4 protect table:</p>\n\n<pre><code>write user * * -//.../*.suo\nwrite user * * -//.../*.obj\nwrite user * * -//.../*.ccscc\n</code></pre>\n\n<p>I remember doing this before, but I don\'t have the necessary permissions to test this here. Check out <a href="http://www.perforce.com/perforce/doc.092/manuals/p4sag/p4sag.pdf" rel="nofollow noreferrer">Perforce\'s Sysadmin guide</a> and try it out</p>\n'}, {'answer_id': 3883647, 'author': 'Warren  P', 'author_id': 84704, 'author_profile': 'https://Stackoverflow.com/users/84704', 'pm_score': 2, 'selected': False, 'text': "<p>HISTORICAL ANSWER - no longer correct. At the time this was written originally it was true;</p>\n\n<p>You can not write and check in a file that the server will use to make ignore rules; general glob or regexp file pattern ignore in perforce.   </p>\n\n<p>Other answers have global server configurations that are global (and not per folder).\nThe other answers show things that might work for you, if you want one line in your view per folder times number of extensions you want to ignore in that single folder, or that provide this capability in WebSphere Studio plugins only, or provide capability for server administrators, but not available to users.</p>\n\n<p>In short, I find Perforce really weak in this area. While I appreciate that those who use the Eclipse Plugin can use <code>.p4ignore</code>, and I think that's great, it leaves those of us that don't, out in the dark.</p>\n\n<p>UPDATE: See accepted answer for new P4IGNORE capability added mid-2012.</p>\n"}, {'answer_id': 4973027, 'author': 'kevin cline', 'author_id': 229810, 'author_profile': 'https://Stackoverflow.com/users/229810', 'pm_score': 1, 'selected': False, 'text': '<p>I have found it easiest to reconcile offline work using a BASH script like this one:</p>\n\n<pre><code>#!/bin/bash\n# reconcile P4 offline work, assuming P4CLIENT is set\nif [ -z "$P4CLIENT" ] ; then echo "P4CLIENT is not set"; exit 1; fi\nunset PWD # confuses P4 on Windows/CYGWIN\n\n# delete filew that are no longer present\np4 diff -sd ... | p4 -x - delete\n\n# checkout files that have been changed.  \n# I don\'t run this step.  Instead I just checkout everything, \n# then revert unchanged files before committing.\np4 diff -se ... | pr -x - edit\n\n# Add new files, ignoring subversion info, EMACS backups, log files\n# Filter output to see only added files and real errors\nfind . -type f \\\n | grep -v -E \'(\\.svn)|(/build.*/)|(/\\.settings)|~|#|(\\.log)\' \\\n | p4 -x - add \\\n | grep -v -E \'(currently opened for add)|(existing file)|(already opened for edit)\'\n</code></pre>\n\n<p>I adapted this from <a href="http://kb.perforce.com/article/2" rel="nofollow">this Perforce Knowledge Base article</a>.</p>\n'}, {'answer_id': 6831195, 'author': 'Derek Prior', 'author_id': 301059, 'author_profile': 'https://Stackoverflow.com/users/301059', 'pm_score': 0, 'selected': False, 'text': '<p>I\'m looking for a .p4ignore like solution as well (and not one tied to a particular IDE). Thus far, the closest thing I\'ve found is p4delta. It sounds like it will do exactly what the original poster was asking, albeit through another layer of indirection.</p>\n\n<p><a href="http://p4delta.sourceforge.net" rel="nofollow">http://p4delta.sourceforge.net</a></p>\n\n<p>Unfortunately, while this does seem to produce the proper list of files, I can\'t get "p4delta --execute" to work ("Can\'t modify a frozen string") and the project has not been updated in year. Perhaps others will have better luck.</p>\n'}, {'answer_id': 9286380, 'author': 'svec', 'author_id': 103, 'author_profile': 'https://Stackoverflow.com/users/103', 'pm_score': 5, 'selected': False, 'text': '<p>This works as of Perforce 2013.1, the new P4IGNORE mechanism was first added in release, 2012.1, described on the Perforce blog here:</p>\n\n<blockquote>\n  <p><a href="https://www.perforce.com/blog/new-20121-p4ignore" rel="nofollow noreferrer">https://www.perforce.com/blog/new-20121-p4ignore</a></p>\n</blockquote>\n\n<p>As it\'s currently described, you set an environment variable "P4IGNORE" to a filename which contains a list of the files to ignore.</p>\n\n<p>So you can check it out to see how you like it.</p>\n'}, {'answer_id': 9538265, 'author': 'Chance', 'author_id': 382186, 'author_profile': 'https://Stackoverflow.com/users/382186', 'pm_score': 3, 'selected': False, 'text': '<p>Perforce Streams makes ignoring files much easier, as of version 2011.1. According to the <a href="http://www.perforce.com/perforce/doc.current/manuals/cmdref/stream.html" rel="nofollow">documentation,</a> you can ignore certain extensions or certain paths in your directory.  </p>\n\n<p>From <code>p4 help stream</code></p>\n\n<pre><code>Ignored: Optional; a list of file or directory names to be ignored in\n                 client views. For example:\n\n                     /tmp      # ignores files named \'tmp\'\n                     /tmp/...  # ignores dirs named \'tmp\'\n                     .tmp      # ignores file names ending in \'.tmp\'\n\n                 Lines in the Ignored field may appear in any order.  Ignored\n                 names are inherited by child stream client views.\n</code></pre>\n\n<p>This essentially does what @raven\'s answer specifies, but is done easier with streams, as it automatically propagates to every work-space using that stream. It also applies to any streams inheriting from the stream in which you specify the ignore types.</p>\n\n<p>You can edit the stream via <code>p4 stream //stream_depot/stream_name</code> or right-clicking the stream in p4v\'s stream view.  </p>\n\n<p>And as @svec noted, the ability to specify ignore files per workspace is coming soon, and is in fact in <a href="http://www.perforce.com/blog/120130/new-20121-p4ignore" rel="nofollow">P4 2012.1 beta.</a></p>\n'}, {'answer_id': 13126496, 'author': 'Colonel Panic', 'author_id': 284795, 'author_profile': 'https://Stackoverflow.com/users/284795', 'pm_score': 6, 'selected': False, 'text': '<p>Yes, But.</p>\n\n<p>Perforce version 2012.1 added a feature known as <a href="http://www.perforce.com/blog/120130/new-20121-p4ignore">p4ignore</a>, inspired by Git. However the Perforce developers made a change to the behaviour, without justification, that happens to make the feature a lot less useful.</p>\n\n<p>Whilst Git takes rules from all <a href="https://www.kernel.org/pub/software/scm/git/docs/gitignore.html"><code>.gitignore</code></a> files, Perforce doesn\'t know where to look until you specify a filename in an environment variable <code>P4IGNORE</code>. This freedom is a curse. You can\'t hack on two repositories that use different names for their ignore files. </p>\n\n<p>Also, Perforce\'s ignore feature doesn\'t work out the box. You can set it up  easily enough for yourself, but others don\'t benefit unless they explicitly opt-in. A contributor who hasn\'t may accidentally commit unwelcome files (eg. a <code>bin</code> folder created by a build script).</p>\n\n<p>Git\'s ignore feature is great because it works out the box. If the <code>.gitignore</code> files are added to the repository (<a href="https://github.com/search?q=extension%3A.gitignore">everyone does this</a>), they\'ll work out the box for everyone. No-one will accidentally publish their private key.</p>\n\n<p>Amusingly, the <a href="http://www.perforce.com/perforce/doc.current/manuals/cmdref/env.P4IGNORE.html">Perforce docs</a> shows \'.p4ignore\' as an example ignore rule, which is backwards! If the rules are useful, they should be shared as part of the repository. </p>\n\n<hr>\n\n<p>Perforce could still make good on the feature. Choose a convention for the file names, say <code>p4ignore.txt</code>, so the feature works out the box. Drop the <code>P4IGNORE</code> environment variable, it\'s counterproductive. Edit the docs, to encourage developers to share useful rules. Let users write personal rules in a file in their home folder, <a href="https://www.kernel.org/pub/software/scm/git/docs/gitignore.html">as Git does</a>.</p>\n\n<p>If you know anyone at Perforce, please email them this post.</p>\n'}]
['https://Stackoverflow.com/questions/55449', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4872/']