<p>It happens to me all the time. I accidentally version a file, I do not want to be versioned (i.e. developer/machine specific config-files).</p>

<p>If I commit this file, I will mess up the paths on all the other developer machines - they will be unhappy.</p>

<p>If I do delete the file from versioning, it will be deleted from the other developers machines - they will be unhappy.</p>

<p>If I choose to never commit the file, I always have a "dirty" checkout - I am unhappy.</p>

<p>Is a clean way to "unversion" a file from revision-control, that will result in no-one being unhappy?</p>

<p>edit: trying to clarify a bit: I have already commited the file to the repository and I want to only remove it from versioning - I specifically do not want it to be physically deleted from everyone doing a checkout. I initially wanted it to be ignored.</p>

<p>Answer: If I could accept a second answer, it would be <a href="https://stackoverflow.com/questions/27695/how-to-unversion-a-file-in-either-svn-andor-git#27727">this</a>. It answers my question with respect to git - the accepted answer is about svn.</p>

[{'answer_id': 27696, 'author': 'Glenn Slaven', 'author_id': 2975, 'author_profile': 'https://Stackoverflow.com/users/2975', 'pm_score': 3, 'selected': False, 'text': "<p>If you accidentally 'add' a file in svn &amp; you haven't committed it, you can revert that file &amp; it will remove the add.</p>\n"}, {'answer_id': 27701, 'author': 'Sergio Acosta', 'author_id': 2954, 'author_profile': 'https://Stackoverflow.com/users/2954', 'pm_score': 2, 'selected': False, 'text': "<p>To remove a file already in source control:</p>\n\n<pre><code>git rm &lt;filename&gt;\n</code></pre>\n\n<p>and then</p>\n\n<pre><code>git commit -m ...\n</code></pre>\n\n<p>You should add every file you want to ignore to the .gitignore file. I additionally always check the .gitignore file to my repository, so if someone checks out the code on his machine, and the file gets generated again, he won't 'see' it as 'dirty'.</p>\n\n<p>Of course if you already committed the file and someone else got your changes on another machine, you would have to alter every local repository to modify the history. At least that's a possible solution with git. I don't think svn would let you do that.</p>\n\n<p>If the file is already on the master repository (git) or in the server (svn), I don't think there is a better solution than just deleting the file in another commit. </p>\n"}, {'answer_id': 27703, 'author': 'Magnus Westin', 'author_id': 2957, 'author_profile': 'https://Stackoverflow.com/users/2957', 'pm_score': 1, 'selected': False, 'text': "<p>For SVN you can revert files you haven't committed yet. In TortoiseSVN you just right click the file in the commit window and choose Revert...</p>\n\n<p>On command line use svn revert [file]</p>\n\n<p>Don't know about GIT since I've never used it.</p>\n"}, {'answer_id': 27704, 'author': 'FantaMango77', 'author_id': 2374, 'author_profile': 'https://Stackoverflow.com/users/2374', 'pm_score': 0, 'selected': False, 'text': "<p>As far as I know there is no easy way to remove an added file from versioning control in svn once it is committed.</p>\n\n<p>You will have to save the file somewhere else and delete it from version control. Than copy the backup back again.</p>\n\n<p>It's a version control system after all... ;)</p>\n"}, {'answer_id': 27707, 'author': 'Greg Hewgill', 'author_id': 893, 'author_profile': 'https://Stackoverflow.com/users/893', 'pm_score': 2, 'selected': False, 'text': '<p>Look up svn:ignore and .gitignore - these features allow you to have extra files in your checkout that are ignored by your RCS (when doing a "status" operation or whatever).</p>\n\n<p>For machine-specific config files, a good option is to check in a file named with an extra ".sample" extension, ie. <code>config.xml.sample</code>. Individual developers would make a copy of this file in <code>config.xml</code> and tweak it for their system. With svn:ignore or .gitignore you can ensure that the unversioned <code>config.xml</code> file doesn\'t show up as dirty all the time.</p>\n\n<p>In response to your edit: If you remove the file from the repository now, then your developers will get a conflict next time they do an update (assuming they have all changed the file for their system). They won\'t lose their local changes, they will be recoverable from somewhere. If they happen not to have made any local changes, then their config file will vanish but they can just re-get the previous one out of source control and use that.</p>\n'}, {'answer_id': 27709, 'author': 'paan', 'author_id': 2976, 'author_profile': 'https://Stackoverflow.com/users/2976', 'pm_score': 0, 'selected': False, 'text': '<p>You can exclude files from subversion with the global-ignore setting<br>\n<a href="http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.2" rel="nofollow noreferrer">http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.2</a><br>\ncheck out the documentation for details</p>\n'}, {'answer_id': 27727, 'author': 'Kai', 'author_id': 2963, 'author_profile': 'https://Stackoverflow.com/users/2963', 'pm_score': 3, 'selected': False, 'text': "<p>Without having tried it...</p>\n\n<p>In git, if your changes haven't been propagated to another repository, you <em>should</em> be able to <code>git rm</code> the affected file(s), <code>git rebase --interactive</code> to reorder the deletion commit to be just after the commit in which you accidentally added the offending files, and then squash those two commits together.</p>\n\n<p>Of course, this won't help if someone else has pulled your changes.</p>\n"}, {'answer_id': 27735, 'author': 'Sir Rippov the Maple', 'author_id': 2822, 'author_profile': 'https://Stackoverflow.com/users/2822', 'pm_score': 2, 'selected': False, 'text': "<p>It sounds like you have already added and committed the file to subversion (I assume that you are using Subversion). If that is the case, then there are only two ways to remove that file:</p>\n\n<ol>\n<li>Mark the file as deleted and commit.</li>\n<li>Perform an <code>svnadmin dump</code>, filter out the revision where you accidentally committed the file and perform an <code>svnadmin load</code>.</li>\n</ol>\n\n<p>Trust me, you don't really want to do number 2. It will invalidate all working copies of the repository. The best is to do number 1, mark the file as ignored and apologise.</p>\n"}, {'answer_id': 35913, 'author': 'dbr', 'author_id': 745, 'author_profile': 'https://Stackoverflow.com/users/745', 'pm_score': 2, 'selected': False, 'text': "<p>To remove a file entirely from a git repository (Say you commited a file with a password in it, or accidently commited temporary files)</p>\n\n<pre><code>git filter-branch --index-filter 'git update-index --remove filename' HEAD\n</code></pre>\n\n<p>Then I think you have to commit, and push -f if it's in remote branches (remember it might annoy people if you start changing the repository's history.. and if they have pulled from you before, they could still have the file)</p>\n"}, {'answer_id': 36814, 'author': 'Damien Diederen', 'author_id': 3844, 'author_profile': 'https://Stackoverflow.com/users/3844', 'pm_score': 0, 'selected': False, 'text': '<blockquote>\n  <p>I there f I choose to never commit the file, I always have a "dirty" checkout - I am unhappy.</p>\n</blockquote>\n\n<p>With regard to this particular point, you might want to <code>.gitignore</code>\nthe file as other have suggested, or to use a scheme like the one\ndescribed in <a href="https://stackoverflow.com/questions/6009/how-do-you-deal-with-configuration-files-in-source-control#36767">this\nanswer</a>\nof mine.</p>\n'}, {'answer_id': 1066304, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 6, 'selected': True, 'text': '<p>SVN version 1.5 supports removing/deleting a file from a repository with out losing the local file</p>\n\n<p>taken from <a href="http://subversion.tigris.org/svn_1.5_releasenotes.html" rel="noreferrer">http://subversion.tigris.org/svn_1.5_releasenotes.html</a> </p>\n\n<p>New --keep-local option retains path after delete..</p>\n\n<p>Delete (remove) now takes a --keep-local option to retain its targets locally, so paths will not be removed even if unmodified.</p>\n'}, {'answer_id': 2978194, 'author': 'wxs', 'author_id': 12981, 'author_profile': 'https://Stackoverflow.com/users/12981', 'pm_score': 6, 'selected': False, 'text': '<p>In Git, in order to delete it from the tree, but NOT from the working directory, which I think is what you want, you can use the --cached flag, that is:</p>\n\n<pre><code>git rm --cached &lt;filename&gt;\n</code></pre>\n'}, {'answer_id': 9799129, 'author': 'Manu Manjunath', 'author_id': 495598, 'author_profile': 'https://Stackoverflow.com/users/495598', 'pm_score': 1, 'selected': False, 'text': "<p>Two simple steps in SVN:<br>\n1. Add this directory in parent directory's svn:ignore property:<br>\n</p>\n\n<pre><code>svn propedit svn:ignore .  \n</code></pre>\n\n<p>2. Remove directory:<br>\n</p>\n\n<pre><code>svn rm mydir\n</code></pre>\n\n<p>3. Commit</p>\n\n<p>Please note that when other developers do a <strong>svn update</strong>, that directory <strong>will not</strong> get deleted. SVN just unversions it instead.</p>\n"}, {'answer_id': 35891315, 'author': 'PerfectGamesOnline.com', 'author_id': 929170, 'author_profile': 'https://Stackoverflow.com/users/929170', 'pm_score': 0, 'selected': False, 'text': '<p>You can unversion all files in current directory with this command. The <code>sed</code> bit reverses the order so svn can process it:</p>\n\n<pre><code>find . | sed \'1!G;h;$!d\'| awk \'{print "svn rm --keep-local " $1}\'\n</code></pre>\n\n<p>As already stated in other answers, single file is unversioned with this:</p>\n\n<pre><code>svn rm --keep-local yourFileNameXXX\n</code></pre>\n'}, {'answer_id': 41001400, 'author': 'live-love', 'author_id': 436341, 'author_profile': 'https://Stackoverflow.com/users/436341', 'pm_score': 0, 'selected': False, 'text': "<p>In Windows, if what you are looking for is copying the folder to another location and removing it from git, so that you don't see the icons anymore, you just delete the .git folder. The .git folder is hidden, so you have to go to Organize / Folder and Search Options, Display hidden Files option, under your main folder. It should unversion it.</p>\n"}]
['https://Stackoverflow.com/questions/27695', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1870/']