Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "unversion" a file in either svn and/or git

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).

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

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

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

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

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.

Answer: If I could accept a second answer, it would be this. It answers my question with respect to git - the accepted answer is about svn.

like image 211
Mo. Avatar asked Aug 26 '08 10:08

Mo.


People also ask

How do I Unversion a file in SVN?

In existing posts (see How to "unversion" a file in either svn and/or git) the accepted answer is generally to run svn rm FILE or svn rm --keep-local FILE , and then set the svn:ignore property if desired.

How to remove files from svn using TortoiseSVN?

Use TortoiseSVN → Delete to remove files or folders from Subversion. When you TortoiseSVN → Delete a file or folder, it is removed from your working copy immediately as well as being marked for deletion in the repository on next commit. The item's parent folder shows a “modified” icon overlay.

How to remove subversion from folder?

Just remove the . svn folder inside the required folder then the control will be automatically removed. Show activity on this post. This will add an item called "Delete SVN Folders" to your right click menu.


1 Answers

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:

git rm --cached <filename> 
like image 152
wxs Avatar answered Sep 17 '22 19:09

wxs