清除git本地缓存 [英] Clear git local cache

查看:3253
本文介绍了清除git本地缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我即将提交的Webstorm项目,但在按下Git Windows GUI中的提交按钮之前,我记得我不想提交 .idea 文件夹内容。

因此,我使用自动为某些IDE生成 .gitignores 的网站,并将它添加到我的 .gitignore 文件。

所有 .idea 显式忽略的文件仍然显示为提交,尽管删除并重新添加了有问题的文件。



我还提交了没有任何其他文件的gitignore文件,并重新粘贴了我的内容,但它仍然不会忽略.idea文件。



如何让Git刷新或清除其缓存?

我尝试了/进入有问题的目录,然后键入

git clean -n



但没有文件显示。

解决方案


显式忽略的所有.idea文件仍然显示为提交


您必须从暂存区域中删除它们

  git rm --cached .idea 

现在您必须提交这些更改,并且从这一点开始它们将被忽略。

一旦git开始跟踪更改,即使将它们添加到稍后的 .gitignore 文件中,它也不会停止跟踪它们。 p>

必须明确删除它们并提交您可以手动删除,以便完全忽略它们。


I have a Webstorm project that I was about to commit, but before pressing the commit button in the Git Windows GUI, I remembered that I don't want to commit my .idea folder content.

So I used the website that auto generates .gitignores for certain IDEs and added it to my .gitignore file.

All .idea files that are explicitly ignored are still showing up to commit, despite me removing and re-added the files in question.

I've also committed the gitignore file without any other files, and re-pasted my content, but it still is not ignoring the .idea files.

How do I tell Git to refresh or clear its cache?
I tried /cd ing into the directory in question, and typing

git clean -n

but no files show up.

解决方案

All .idea files that are explicitly ignored are still showing up to commit

you have to remove them form the staging area

git rm --cached .idea

now you have to commit those changes and they will be ignored from this point on.
Once git start to track changes it will not "stop" tracking them even if they were added to the .gitignore file later on.

You must explicitly remove them and than commit your removal manually in order to fully ignore them.

这篇关于清除git本地缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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