【问题标题】:gitignore not ignoring opencv2.frameworkgitignore 不忽略 opencv2.framework
【发布时间】:2017-06-30 00:55:23
【问题描述】:

我试图让 git 忽略我已导入项目的 opencv2.framework。但是,即使我将 opencv2.framework 添加到我的 .gitignore 中,每次我在终端上运行 git status 时,所有 opencv2.framework 文件都会显示为新文件。有人可以帮忙吗?谢谢!这是我的 .gitignore 文件的样子:(我在 ##Various Settings 下编写了 opencv2.framework)

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
opencv2.framework/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output

【问题讨论】:

标签: swift xcode git opencv gitignore


【解决方案1】:

以防万一,看看之后git状态有没有变化:

cd /path/to/my/repo
git rm -r --cached opencv2.framework/

如果是(并且您不再看到 opencv2.framework/ 文件),请提交您当前的状态。

你需要执行git rm -r --cached:

  • 在要删除的文件夹的父仓库中(opencv2.framework/ 的父仓库)。
    添加并提交(并最终推送),以便从 git 存储库(但不是从磁盘,感谢 --cached 选项)记录该删除;
  • 为了删除那些跟踪文件,.gitignore 规则仅适用于未跟踪文件。

【讨论】:

  • 我输入了那个命令,它返回“fatal: path spec 'opencv2.framework/' did not match any files”
  • 所以我找到了一个临时解决方法,因为我使用的是 Xcode:在提交 .gitignore(使用 opencv2.framework)时,我手动取消选中所有 opencv2 文件以防止它们提交并推送到我的遥控器。但是,当我检查 git status 时,opencv2 文件仍然显示为新文件,因此 git 似乎没有忽略它们。我尝试再次运行“git rm -r --cached opencv2.framework”,并返回相同的致命消息。
  • @jx8 奇怪:你在正确的 fodler(opencv2.framework/ 的父级)中做了 git rm。是否存在小写/大写问题,Git 存储库知道该文件夹带有大写?
  • 啊,我太愚蠢了——我在错误的文件夹中(必须使用 ls 来检查内容)。我运行了 git rm 命令,它似乎已经删除了 opencv2 文件。我应该采取的下一步是什么?我为这个简单的问题道歉(我是 git 新手),但是“git rm -r --cached afile”到底是做什么的?
  • 添加并提交。然后检查你的 git 状态。现在应该忽略文件夹内容。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-06
  • 1970-01-01
  • 1970-01-01
  • 2022-11-16
  • 2019-04-29
  • 2018-05-02
  • 2016-12-25
相关资源
最近更新 更多