[Feature request] Remove file from version control
Answered
Hi,
With this post I would like to submit a feature request.
It would very usefull if a user could select one or more files, and choose to remove them from the version control system, leaving the file(s)/folder(s) intact on the local file system.
This could be very usefull in the project window, as well as in the "Version Control" tab.
Thank you.
Please sign in to leave a comment.
Hello Tim,
Thank you for the feedback, however I would like to note that we already got such requests and they were declined.
Check this one, for example: https://youtrack.jetbrains.com/issue/IDEA-107359
The idea behind this is that we try to support common workflows, while removing files from VCS tracking without actually deleting it is relatively rare operation, and you can do this using the command line or terminal within IDEA.
well. I just imported an old Java project and when I went to add the source folder to Git, I discovered that Intellij had added every since folder and file to Git tracking. We are talking build scripts, shell scripts to help with build, configuration files, compiled .jar and .class files...everything. I wasn't prompted to add these items every though in settings->versions I have "ask for each file" checked.
can we at least get a link to procedures to remove files from tracking from the command line using git?
To stop tracking files in git (remove from git but keep locally), just execute git rm --cached path/to/file, Make sure to commit such deletion from the command line as well.
Dmitri - I did that, but I had to open a terminal and execute the command multiple times for directories and files to remove undesired items.
It would be more efficient to select the same files and directories in the app, right-click, and select "remove from tracking" or similar.
What is the use case of removing the files from VCS?
If it is to ignore them, there seems to be a better way to support this - as a part of ignore functionality, e.g. https://youtrack.jetbrains.com/issue/IDEA-57620 or https://youtrack.jetbrains.com/issue/IDEA-21006
Any other use-case?
The use case was that I had an existing non-PyCharm project that I imported into PyCharm. It was structured for Maven as per the standards of a previous development team, where it had folders for build , deploy, artifacts, etc, all underneath the parent directory. PyCharm added all of the those files to the the repo in addition to the "src" folder which contained the source code.
I was looking for an easy way to undo that mistake. By the way, PyCharm did not indicate that it was adding anything to version control, no prompts, no warning, nothing,
The mentioned action is needed only for committed files. If files were added for commit by mistake, but not committed, you could just Revert the addition.
You could also Undo the entire commit unless it has been pushed, and then commit again with the correct set of files.
IDE adds files to VCS automatically only if the corresponding option is enabled at Settings - Version Control - Confirmation, and files were created in the IDE. Since it is a maven project, maven import could have affected this somehow - see related https://youtrack.jetbrains.com/issue/IDEA-18710. However, all changes (additions, deletions, modifications) are shown in the Local changes tab, and subsequently in the commit dialog. So you always see what you commit, and could unselect or revert files you do not want to commit.
Moreover, with the way IDE commits currently (using git commit --only) it is not possible to commit deletion from VCS without deleting the file itself. See https://youtrack.jetbrains.com/issue/IDEA-138847
Adding this feature would be a huge improvement. If the commit of the deletion results in the selfdestruction of the file on the local file system, just backup the file to a local temporary location, and restore the file after the commit was pushed... Just a simple fix i think ... :-)
The issue with committing of such a change is not primarily the reason for not adding this. Please see the reasoning in https://youtrack.jetbrains.com/issue/IDEA-107359
Why would you need to stop tracking a file and at the same time leave it as untracked, without ignoring?
Any progress on this very very useful feature?
Please see https://stackoverflow.com/a/45928425/2000323
Dmitriy Smirnov this is absolutely not rare. I've made this same mistake dozens of times:
Now I've got a tracked file that should be ignored, and every single time go looking for the “right click > untrack” option and it's not there and I think how is this not possible. Then I wonder if maybe “Rollback” does this, but I don't know what that word means (rollback adding the file? Rollback putting stuff in the file?) and don't want to delete the file. So I Google how to untrack a file with `git` and run the command and get a little bit annoyed that this isn't possible or isn't clear and isn't easy, and that even if you go and read the help, it's still not clear what's going to happen to the file you added if you click ‘rollback’.
By the way, if you want ‘proof’ that this is confusing, ask a smart AI how to do this and watch it say all sorts of incorrect things about your product.
@David Gilbertson Hi, thanks for sharing your use case, and I agree having a menu to untrack the file would be really convenient in your scenario.
I have attached your scenario privately in the https://youtrack.jetbrains.com/issue/IJPL-73216/Ability-to-remove-files-from-version-control-but-keep-them-locally to let the developer know about it.
As a workaround, please use git rm --cached path/to/file to untrack the file.