Ignoring files in Git after they are committed

I recently switched to git.

In my previous and first commit using git, I noticed that it also listed pyc files during commit. I did not think about it and committed and pushed them.

Now I understand that they are constantly updated during development and are very annoying to see them on the list. It just makes too much noise.

I did some research and did echo "*.pyc" >> .gitignore in the project directory.

This did not help, although pyc files are still showing. Maybe because I previously committed these pyc files, I can no longer ignore them? (since they are being tracked now, and the state has changed again). If so, am I cursed forever or is there still hope to delete files in the flashback from the repository?

thanks

+4
source share
1 answer

Just git rm .pyc files and make sure your .gitignore set to ignore them from now on. You are correct that git will not ignore committed files because they are already added. If you do not want to delete the drive, use git rm --cached to delete the files. It just removes them from the index without removing them from disk.

+5
source

Source: https://habr.com/ru/post/1435634/


All Articles