添加 Git 存储库中的目录后忽略该目录
我已经学会了如何在git中排除整个目录(添加一行 bin/
到 .gitignore
)。我已经学会了如何“事后”忽略文件(即在将它们添加到 git 之后):
git rm --cached <filename>
如何忽略整个目录(例如 bin/
)之后已添加到 Git 存储库?
我尝试了 git rm --cached bin/ 但收到的只是错误:
致命:路径规范“bin/”与任何文件都不匹配
当我尝试(在 .git 存在的根目录)git rm --cached MyProj/bin/
时,错误是不同的:
致命:未删除“MyProj/bin/” 不带 -r 递归
这意味着什么?我现在需要提交和/或分支吗?
I've learned how to exclude an entire directory in git (add a line bin/
to .gitignore
). And I've learned how to ignore files "after the fact" (i.e. after they have been added to git):
git rm --cached <filename>
How do I ignore an entire directory (e.g. bin/
) after it has been added to a Git repo?
I tried git rm --cached bin/
but all I received was the error:
fatal: pathspec 'bin/' did not match any files
When I tried (at the root directory, where .git exists) git rm --cached MyProj/bin/
the error is different:
fatal: not removing 'MyProj/bin/'
recursively without -r
What does this mean and will I need to commit and/or branch this now?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能够在存储库的根目录中使用
git rm -r --cached bin/
(注意递归-r
)来实现它 - 你在谈论 < em>找到 bin 目录并取消跟踪它们?在反映排除之前,您必须
提交
。我刚刚看到你在 Windows 上。这是在 OSX 上的终端中,请注意。
I was able to get this working with
git rm -r --cached bin/
(note the recursive-r
)in the root of the repo - are you talking about finding the bin directories and untracking them?You will have to
commit
before the exclusion is reflected.I just saw that you were on Windows. This was in Terminal on OSX, just a heads up.
在 Windows 上:
然后做其他事情。 (
add
和commit
和push
)(请注意,在 Windows 上,您应该在文件夹名称之前使用
./
,就像上面一样。)On windows:
And then do the other stuffs. (
add
andcommit
andpush
)(Note that on windows you should use
./
before the folder name, just like above.)