Git忽略本地删除的文件夹 [英] Git ignore locally deleted folder

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

问题描述

我有一个Ruby on Rails应用程序,它在 vendor / rails 存在时崩溃,但如果不存在则正常工作。我需要保留此文件夹在我的本地副本中删除,以便我可以工作,但我不希望此删除被提交。有人把它放在那里是有原因的。



那么如何删除这个文件夹而不会出现在 git status 作为一千个被删除的文件?很明显, .gitignore 不起作用,因为你不能忽略已经被跟踪的文件。上面列出的解决方案都不是 git update-index -

  git ls  

-files - 删除 -z | git update-index - 假定不变 -z --stdin

请注意,因为这是一个基于索引的操作,你不能设置目录被忽略 - 只有单个文件。如果上游在这些目录中添加了一个文件,您将不得不重复修正。


I have a Ruby on Rails application which crashes when vendor/rails is present but works fine if it is not. I need to keep this folder deleted in my local copy so that I can work, but I don't want this deletion to ever be committed. Someone put it there for a reason.

So how do I delete this folder without it coming up in git status as a thousand deleted files? Obviously .gitignore won't work since you can't ignore files which are already tracked. Neither do any of the solutions listed here (git update-index --assume-unchanged) work.

解决方案

 git ls-files --deleted -z | git update-index --assume-unchanged -z --stdin

Note that because this is an index-based operation, you cannot set directories to be ignored – only individual files. If upstream ever adds a file inside those directories, you will have to repeat the fix-up.

这篇关于Git忽略本地删除的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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