26

I'm having a tracked file in git but now I don't want to track it anymore (I don't want it to show up from the next commit but I still want to have it inside the folder).

In the Changes tool window I have set that file as ignored in Configured Ignored Files but somehow when I change that file, the changes still shows up in the change list?

Hải Phong
  • 5,094
  • 6
  • 31
  • 49

3 Answers3

40

As of 2017.3.4, you cannot use the IDEA GUI to perform this command, it must be done from the command line or another tool.

From console:

git rm --cached file
git commit -m'file removed'
echo 'file' >> .gitignore
Charlie
  • 8,530
  • 2
  • 55
  • 53
Vlad Nikitin
  • 1,929
  • 15
  • 17
  • So you mean we must write these in cmd and there is no way to do this in Intellij? – Hải Phong Feb 11 '14 at 14:02
  • 6
    cmd is universal powerful tool, today you are using Intellij, tomorrow Visual studio, in a week - Eclipse, you do not need to learn how to use git every time, just learn it 1 time – Vlad Nikitin Feb 11 '14 at 14:08
  • 22
    Why have any git commands in IntelliJ then? Answer=productivity. It should be included as an option under GIT in the file context menu. – JoshuaDavid Feb 01 '15 at 07:52
  • 6
    I completely agree. I don't want to memorize all the git commands on top of the hundreds of other things I have to memorize. The git integration has 90% of the functions there. Why does intellij keep leaving stuff out like this – 1mike12 Feb 26 '15 at 03:30
  • 2
    @1mike12 I agree it is odd, considering there's the `add` option. At least it's better than the eclipse git plugin! – benscabbia Aug 14 '15 at 17:47
  • 3
    I know for me, I wanted to untrack an entire directory and all it's contents, so I had to put `git rm -r --cached dir/` – Cache Staheli Apr 06 '16 at 15:14
  • Agree with the suggestion of a remove option I don't see why they would have add without the remove it makes no sense forcing you to run commands when you might want to add an entire directory then un-track 1 or 2 files. – Someone May 04 '17 at 09:47
  • If what the OP asks how to do something in their preferred tool (which is the entire point of the question) we don't need to bash their preference in tools. A simple "it cannot be done in that tool, but it can be done in this other one, and here's how" would suffice. ;) – Charlie Apr 27 '18 at 08:13
2

IntelliJ doesn't allow you to untrack added files, but you quit easily can get to the same result as follows:

  1. In IntelliJ open the Version Control Tool Window
  2. In the Local Changes tab: create a new change list (do NOT make it active)
  3. You can add all the files you would not want to commit to this new changelist.
  4. Commit and push only the other changelist(s)

Like so you don't have to botter about (not) adding files. You can add all files and drag 'm into the new changelist if you don't want to commit these files.

Be aware though, when also using git cli, the files are still added to the working directory and will be taken into account when committing. Use the other answers on this page.

Erijk
  • 380
  • 3
  • 8
-1

in WebStorm 2018.2.1 you can do it like this: in version control tab right click unversioned files and ignore file