user3453226
user3453226

Reputation:

Remove file from Version Control in IntelliJ IDEA

I'm using IntelliJ IDEA Community Edition 2016.1. I've put my project under Git, hosted it on GitHub.

When I first hit that Share Project on GitHub button, every single file was selected to be put under version control.

Now I want to exclude the module IML file from version control. Obliviously, I want to keep it on my hard disk. Unfortunately, I cannot find a way to do this. How do I achieve this?

I tried to delete it from the web interface, but I'm getting some fatal errors while pulling/pushing.

Upvotes: 50

Views: 67961

Answers (3)

Gerd
Gerd

Reputation: 2603

for subversion:

  • go to file properties context menu > copy path
  • open terminal use "svn rm --keep-local" to remove

    svn rm --keep-local /aa/bb/cc/myfile.txt

Upvotes: 2

XYz Amos
XYz Amos

Reputation: 1493

There is a little trick.

  • Go to File Menu-> Settings | Version Control | Confirmation, then check the Show options before adding to version control setting under the When files are created section. Alternatively, you could check Do not add. It is mandatory that you do not check Add silently.
  • Delete the file you don't want to be tracked by VCS.
  • Press Ctrl + Z to undo the removal of the file. If IDE shows a popup window which lets you choose whether or not to add the new file to VCS, click No.
  • Commit your local changes, and the files are removed from VCS.

Upvotes: 80

CodeWizard
CodeWizard

Reputation: 141946

Once you commit the file it will begin to be tracked.
In order to remove the file from this point you have to remove them from the repository.

What you need to do now is to delete the entire .idea folder, commit the deletion, add the idea extension to your .gitignore file.


Explaining how to do from command line, can be done via IDEA as well.

# Remove the file from the repository
git rm --cached .idea/

# now update your gitignore file to ignore this folder
echo '.idea' >> .gitignore

# add the .gitignore file
git add .gitignore

git commit -m "Removed .idea files"
git push origin <branch>

Upvotes: 35

Related Questions