在已经跟踪大量文件的现有存储库上应用gitignore [英] Apply gitignore on an existing repository already tracking large number of files
问题描述
我的存储库中有一个现有的Visual Studio项目。我最近在我的项目下添加了一个.gitignore文件,我假设它告诉Git忽略文件中列出的文件。
我的问题是,所有这些文件都已被跟踪,据我所知,Git不会忽略在将规则添加到此文件之前已经跟踪的文件忽略它。
建议使用: git rm --cached
并手动取消跟踪它们,但这将永远让我永远经历他们一个接一个。
我曾想过删除存储库并重新创建它,但这次使用.gitignore文件存在,但必须有更好的方法来执行此操作。
此答案 a>解决了我的问题: 提交所有挂起的更改,然后运行以下命令: 这将删除索引中的所有内容,然后运行: 提交: I have an existing Visual Studio project in my repository. I recently added a .gitignore file under my project and I assume that tells Git to ignore the files listed in the file. My problem is that all those files are already being tracked and as far as I know Git will not ignore a file that was already tracked before a rule was added to this file to ignore it. It was suggested to use: I thought about deleting the repository and recreating it again but this time with .gitignore file present, but there must be a better way to do this. This answer solved my problem: Commit all pending changes, then run this command: This removes everything from the index, then just run: Commit it:
这篇关于在已经跟踪大量文件的现有存储库上应用gitignore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
git rm -r --cached。
git add。
git commit -m.gitignore现在正在运行
git rm --cached
and manually un-track them but that's going to take me forever to go through them one by one. git rm -r --cached .
git add .
git commit -m ".gitignore is now working"