To be able to ignore files that have been track, such as stopping tracking a file but not removing it from the repository. You can use the following command:
The code is as follows |
Copy Code |
git rm–cached filename |
The above command is used to delete a single cached file.
Delete cache directory Use the following command:
The code is as follows |
Copy Code |
Git rm-rf–cached foldername |
If you want to ignore a lot of files or folders, can not be deleted one by one.
Reset all caches, flush ignored files after commit
To run the command:
The code is as follows |
Copy Code |
Git rm-r–cached. |
This command will remove all cached indexes and then run the following command to add all the files:
The code is as follows |
Copy Code |
git Add. |
Submit it:
The code is as follows |
Copy Code |
Git commit-m ". Gitignore is now working" |
. Gitignore Other uses
Gitignore also has a usage, an empty. gitignore file can be considered as a placeholder. This becomes useful when you need to create an empty log directory for your project. You can create a log directory in which to place an empty. gitignore file. So when you clone this repo, Git will automatically create an empty log directory.