To untrack a single file that has already been added/initialized to your repository, ie , stop tracking the file but not delete it from your system use: git rm --cached filename
(要取消跟踪已添加/初始化到存储库中的单个文件, 即停止跟踪文件但不将其从系统中删除,请使用: git rm --cached filename
)
To untrack every file that is now in your .gitignore
:
(取消跟踪.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"
To undo git rm --cached filename
, use git add filename
.
(要撤消git rm --cached filename
,请使用git add filename
。)
Make sure to commit all your important changes before running git add .
(确保在运行git add .
之前提交所有重要更改git add .
)
Otherwise, you will lose any changes to other files. (否则,您将丢失对其他文件的任何更改。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…