How to Git ignore files that were added to the repository
If you update .gitignore
to ignore a file that you previously committed to the repository you might expect that the file gets automatically removed but it won’t happen.
If the files are in the repositories you have to remove them manually first.
Here is how you can do it.
Note
First commit or discard any outstanding code changes, and then, run the following commands:
Removes the files from the staging area (index):
All files in the current directory
|
|
or a specific directory
|
|
or a specific file
|
|
Add the changes to the staging area and commit.
|
|
|
|
Your .gitignore
should now be respected.