Hải Phong
Hải Phong

Reputation: 5144

How can I untrack a file from a git repository in Intellij

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?

Upvotes: 26

Views: 29859

Answers (3)

Erijk
Erijk

Reputation: 420

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.

Upvotes: 4

Hossein Rezaei
Hossein Rezaei

Reputation: 1

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

Upvotes: -1

Vlad Nikitin
Vlad Nikitin

Reputation: 1951

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

Upvotes: 41

Related Questions