不能git add。它显示警告:无法打开目录

时间:2019-01-27 10:25:48

标签: git warnings add commit

我是编程新手,渴望学习它,将更改从Visual Code保存到github时遇到问题。我已经在VSCode上的Gemfile,gemfile.lock和routes.rb上编辑了文件。但是,当我通过输入git add .将其保存到github时。它没有多次工作。如果我错过该步骤或其他操作,则为Idk,但它始终显示警告。我之前添加的git add也在添加列表中。请帮助,我无法继续上课。谢谢。

xxx-MacBook-Air:~ userxxx$ git add --ignore-errors --force .
warning: could not open directory 'Library/Application Support/MobileSync/': Operation not permitted
warning: could not open directory 'Library/Application Support/CallHistoryTransactions/': Operation not permitted
warning: could not open directory 'Library/Application Support/com.apple.TCC/': Operation not permitted
warning: could not open directory 'Library/Application Support/CallHistoryDB/': Operation not permitted
warning: could not open directory 'Library/Saved Application State/com.vsco.vscokeys1.savedState/': Permission denied
warning: could not open directory 'Library/Saved Application State/com.adobe.flashplayer.installmanager.savedState/': Permission denied
warning: could not open directory 'Library/Saved Application State/com.bitrock.appinstaller.savedState/': Permission denied
warning: could not open directory 'Library/IdentityServices/': Operation not permitted
warning: could not open directory 'Library/Messages/': Operation not permitted
warning: could not open directory 'Library/HomeKit/': Operation not permitted
warning: could not open directory 'Library/Mail/': Operation not permitted
warning: could not open directory 'Library/Safari/': Operation not permitted
warning: could not open directory 'Library/Suggestions/': Operation not permitted
warning: could not open directory 'Library/Containers/com.apple.VoiceMemos/': Operation not permitted
warning: could not open directory 'Library/Containers/com.apple.Home/': Operation not permitted
warning: could not open directory 'Library/Containers/com.apple.Safari/': Operation not permitted
warning: could not open directory 'Library/Containers/com.apple.iChat/': Operation not permitted
warning: could not open directory 'Library/Containers/com.apple.mail/': Operation not permitted
warning: could not open directory 'Library/Containers/com.apple.stocks/': Operation not permitted
warning: could not open directory 'Library/PersonalizationPortrait/': Operation not permitted
warning: could not open directory 'Library/Metadata/CoreSpotlight/': Operation not permitted
warning: could not open directory 'Library/Metadata/com.apple.IntelligentSuggestions/': Operation not permitted
warning: could not open directory 'Library/Cookies/': Operation not permitted
warning: could not open directory 'Library/Caches/com.apple.safaridavclient/': Operation not permitted
warning: could not open directory 'Library/Caches/com.apple.HomeKit.configurations/': Operation not permitted
warning: could not open directory 'Library/Caches/CloudKit/com.apple.Safari/': Operation not permitted
warning: could not open directory 'Library/Caches/com.apple.Safari/': Operation not permitted
warning: could not open directory 'Library/Caches/com.apple.Safari.SafeBrowsing/': Operation not permitted

我希望可以将更改添加到我的github。

1 个答案:

答案 0 :(得分:0)

该错误表明,git无权从它不应该访问的某些路径读取内容,因为它们是操作系统的受保护部分,只有管理员可以访问。

您正在用户的主目录中执行git命令。为了使git add命令起作用,您必须在git信息库的目录中执行它。如果您的存储库实际上是您的主目录,那实际上不是一个好主意,您应该立即更改它。您应该每个项目有一个存储库。 Git会将其中的所有文件和文件更改以及所有子目录保存到该存储库中,如果存储库是您的主目录,则不好。