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.
Use Git update-index to ignore changes To resume tracking, run the git update-index command with the --no-skip-worktree flag. Or, you can temporarily stop tracking a file and have Git ignore changes to the file by using the git update-index command with the assume-unchanged flag.
To remove a file from Git, you have to remove it from your tracked files (more accurately, remove it from your staging area) and then commit. The git rm command does that, and also removes the file from your working directory so you don't see it as an untracked file the next time around.
In this git gives a suggestion to the user that the tracked file on staging can be removed by using git rm --cached <file> . To practice the command, let's try removing the same CustomerData_IND. txt file, which was added earlier. To remove the desired file, type git rm --cached CustomerData_IND.
The two steps to stop tracking a file that you have been tracking are:
.gitignore
git rm --cached [file name]
I do not know how to do that from within PyCharm
, however.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With