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

查看:780
本文介绍了添加后从Git仓库中忽略目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  git rm --cached< filename> 

如何忽略整个目录(例如 bin / 之后它已被添加到Git仓库吗?



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


fatal:pathspec'bin /'没有任何文件匹配


当我尝试(在根目录中,存在.git时) git rm --cached MyProj / bin / 错误不同:
$ b


致命:未删除'MyProj / bin /'
递归地不带-r


这意味着什么,我现在需要提交和/或分支它?

解决方案

我可以通过 git rm -r --cached bin / (注意递归的 -r )在repo的根目录下 - 你是在谈论寻找bin目录和untracking他们?

Y在排除反映之前,您必须提交



我刚刚看到您在Windows上。这是在OSX的终端,只是一个头。


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?

解决方案

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.

这篇关于添加后从Git仓库中忽略目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆