Brian Leach
Brian Leach

Reputation: 4154

How to stop tracking folder / files in git from IDE

I use PyCharm as my IDE and I love it. I use git as my version control system. I use it from within PyCharm (I don't know how to use it effectively any other way). Every once in a while, I will want to stop tracking a file in git. Whether I just don't want to track it anymore, or some .xml file somehow got added to the git list that always changes.

Is it true that there is no straitforward way to stop tracking a file or folder in git? The methods I have found seem like I am spending way too much time to do something that I would think should be simple?

First thing I always do is add them to the .gitignore file but that doesn't help after the fact.

Upvotes: 10

Views: 7655

Answers (5)

Lucky_Guess_711
Lucky_Guess_711

Reputation: 1

Maybe a bit of a glitch in PyCharm (using 2024.3), but I found if you delete the file from Commit view, then do a Ctrl-z to undo the delete, the file will be restored on local disk but will remain as "deleted" for the commit changes. You can commit/push the change and it will delete it from the repo while keeping it local.

Upvotes: 0

Comrade Che
Comrade Che

Reputation: 732

You can use Rollback to stop an accidentally started file versioning:

enter image description here

Upvotes: 4

Paul
Paul

Reputation: 366

Open the Version Control tool window (Alt+9) and switch to the Local Changes tab. Click the Configure Ignored Files icon, and press the + sign to add files/folders that you want ignored. While this will work in the IDE, it is not the same as adding them in the .gitignore file.

Upvotes: 1

Jer_
Jer_

Reputation: 99

The two steps to stop tracking a file that you have been tracking are:

  1. Add the file to the .gitignore
  2. git rm --cached [file name]

I do not know how to do that from within PyCharm, however.

Upvotes: 9

Rafael
Rafael

Reputation: 7242

I am also working with .gitignore to create rules to ignore files and is working perfectly fine within Eclipse and without any IDE.

In general there are some rules to define. Furthermore if you add a rule later and git already track the file you want to ignore, this will not work and you should use a special command to fix that.

In specific according to this site:

If you already have a file checked in, and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, you must untrack the file first, by running the following command in your terminal:

git rm --cached 

Upvotes: 0

Related Questions