How to remove file from Git VCS only
Hi. I have a folder(with 1 file inside it) versioned with Git and have not relised I dont need it - so I now have a problem to remove tracking to this file. I have done the first part which is adding a ignored files rule for the folder, but after refreshing changes panel it still lists it as versioned.
I did a google and it seems it requires a "git rm --cached <file>" to stop tracking the file.
Does Phpstorm have anything to help me do this?
Please sign in to leave a comment.
I do that sometimes too, forget to ignore the /.idea/ folder.
I havent found anything to do it from within the IDE yet, so just go to command line and use the command you have above, then commit.
Its gone when i get back to the IDE.
I sware Ive done it before from inside the software
Cant remember how I did it because i know ive never used that git command I posted above
Ive just seen in the sidebar another topic http://devnet.jetbrains.net/message/5454632#5454632
It doesnt seem to have this feature, undertstood. However I agree with these guys it seems unusual to have git add but not remove :)
The only time I've ever wanted to remove somthing from git is when i first put it there and realized oops, mistake.
But git add I use all the time whenever i create a new file. Seams fine to me to not have a git remove.
If you want it as a feature, throw up a feature request in the tracker.
Yeah it is a rare scenario when you think about it. However, I addeded my project to version control while the project was already well established so I added the whole thing at once and assumed I would be deselect the file I dont want to track. That would be much quicker. Now that I know its not possible I obv wont do that again but for new ysers its helpful feature. Yeah i seen the feature request but wont be no use to me anymore really
You can ignore stuff before it goes into git.
if i copied a new file into the project directory at say:
/images/some_junk_image.php
then opened phpstorm, it will appear in the CHANGES panel but be grouped with 'unversioned files'. At this point in time you can right click it, choose ignore and it wont appear in CHANGES again.
That is sometimes useful...
Yeah that seems useful. Thanks Michael
Removing a file from the VCS is a rare operation, so I don't think we need a GUI for it.
That said, the only option is to use a command line to remove a file from the VCS.
Sorry for necroing this thread, but I find the simplest solution is to:
1. Open the file in the PhpStorm editor
2. Select all contents
3. Copy or Cut contents
4. Delete the file
5. Create the file again, and not add it to git when asked
6. Paste the contents back
It's a good idea to make a backup of the file first, just in case something happens.
You just need to rollback the file! it will not be removed physically but only from the VCS
Thank you Aazizi Tarik!
Rolling back is super helpful.
I don't know why Kirill Likhodedov calls this rare. Files are being added to git all the time - when you create, when you copy, etc. And very often it is needed to remove them from git (make the green colour -> red). Rollback is not the proper word for it, not obvious at least.