git项目中有些工程文件是不需要用git管理的,而且每次commit时都会被检测出,比较碍眼。
可通过设置gitignore来管理这些不需要显示的代码。
设置如下:
1. 打开git的项目的根目录中隐藏文件 .gitignore 文件。
vim .gitignore
2.编辑不使用的文件及文件夹。
3. 如果修改gitignore后不起作用,参考下文。
To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use: git rm --cached filename
To untrack every file that is now in your .gitignore
:
First commit any outstanding code changes, and then, run this command:
git rm -r --cached .
This removes any changed files from the index(staging area), then just run:
git add .
Commit it:
git commit -m ".gitignore is now working"