为什么.gitignore不包含以!开头的文件! [英] Why is .gitignore not including a file prefixed by a !

查看:195
本文介绍了为什么.gitignore不包含以!开头的文件!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.gitignore文件如下所示:

  build / 
glucosia.xcodeproj /
! glucosia.xcodeproj / project.pbxproj
core-plot / framework / build
core-plot / framework / CorePlot-CocoaTouch.xcodeproj /
!core-plot / framework / CorePlot-CocoaTouch.xcodeproj /project.pbxproj
.DS_Store
Classes / .DS_Store

奇怪的是, code> glucosia.xcodeproj / project.pbxproj 不会被忽略,就像我期望的那样。

但是, core-plot / framework / CorePlot-CocoaTouch.xcodeproj / project.pbxproj 仍然被忽略。



有什么想法?



谢谢!

解决方案

正如 gitignore 手册页


文件指定git应该忽略的有意未覆盖的文件




如果 glucosia.xcodeproj / project.pbxproj (如评论中的Alan )已被跟踪,您需要将其从缓存中移除,然后gitingore指令才会生效。

  git rm --cached glucosia.xcodeproj / project.pbxproj 

如果该文件已提交,请参阅此答案 git commit --amend 将它从最新的提交中移除)


My .gitignore file reads as follows:

build/
glucosia.xcodeproj/
!glucosia.xcodeproj/project.pbxproj
core-plot/framework/build
core-plot/framework/CorePlot-CocoaTouch.xcodeproj/
!core-plot/framework/CorePlot-CocoaTouch.xcodeproj/project.pbxproj
.DS_Store
Classes/.DS_Store

Strangely, glucosia.xcodeproj/project.pbxproj is not ignored, as I would expect.

But, core-plot/framework/CorePlot-CocoaTouch.xcodeproj/project.pbxproj is still being ignored.

Any ideas?

Thanks!

解决方案

As mentioned in the gitignore man page:

A gitignore file specifies intentionally untracked files that git should ignore

If glucosia.xcodeproj/project.pbxproj (as suggested by Alan in the comments) is already tracked, you need to remove it from the cache, and then the gitingore directive will take effect.

git rm --cached glucosia.xcodeproj/project.pbxproj

If the file was already committed, see this SO answer (git commit --amend to remove it from the latest commit)

这篇关于为什么.gitignore不包含以!开头的文件!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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