添加后从Git仓库中忽略目录(Ignoring a directory from a Git repo after it's been added)

编程入门 行业动态 更新时间:2024-10-09 12:28:37
添加后从Git仓库中忽略目录(Ignoring a directory from a Git repo after it's been added)

我已经学会了如何在git中排除整个目录 (添加一个行bin/到.gitignore )。 而且我已经学会了如何在“事实之后”忽略文件 (即在将它们添加到git之后):

git rm --cached <filename>

如何在添加到Git仓库忽略整个目录 (例如bin/ )?

我试过git rm --cached bin/但我收到的是错误:

致命:pathspec'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?

最满意答案

我能够使用git rm -r --cached bin/ (注意recursive -r )在repo的根目录下工作 - 您是在谈论如何找到 bin目录并解开它们?

排除反映之前,您必须commit 。

我刚刚看到你在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.

更多推荐

本文发布于:2023-08-03 12:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1388951.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:仓库   目录   Git   Ignoring   added

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!