laravel OS X 上的 GitHub 客户端提交失败(“无法添加文件...)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23304734/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:25:32  来源:igfitidea点击:

GitHub Client on OS X Commit Fail ("Failed to add file ...)

gitgithublaravellaravel-4github-for-mac

提问by user1072337

I am trying to commit changes I have made to my code (as usual) from my GitHub client on my Mac OS X Mavericks machine. I added a new package to my project (it's a Laravel project, and I added the package Rocketeer. I also made a few config changes).

我正在尝试从 Mac OS X Mavericks 机器上的 GitHub 客户端提交对代码所做的更改(像往常一样)。我在我的项目中添加了一个新包(这是一个 Laravel 项目,我添加了 Rocketeer 包。我还做了一些配置更改)。

I am getting the error:

我收到错误:

Failed to add file laravel-master/vendor/anahki  

When I uncheck this file in the commit list, it then goes to another file showing this error.

当我在提交列表中取消选中此文件时,它会转到另一个显示此错误的文件。

Failed to add file laravel-master/vendor/illumin

Any idea what is going on? I have never run into these issues. Thank you.

知道发生了什么吗?我从来没有遇到过这些问题。谢谢你。

EDIT:

编辑:

I have narrowed this down to two files that are not being allowed to commit (this is for a Laravel project):

我已将范围缩小到两个不允许提交的文件(这是针对 Laravel 项目的):

These are the errors I get when I try to commit these two folders/files:

这些是我尝试提交这两个文件夹/文件时遇到的错误:

Failed to add file laravel-master/vendor/illuminate/remote/Illuminate/Remote/ to index.

Failed to add file laravel-master/vendor/anahkiasen/rocketeer/ to index.

回答by user3366948

In my case, there was already a .git directory from another imported third-party git repository. I had to removed it, anything worked well.

就我而言,已经有一个来自另一个导入的第三方 git 存储库的 .git 目录。我不得不删除它,一切都很好。

回答by FK82

I had the same problem. There was an existing .gitrepository at the location i wanted to create the new one. I deleted it and created a new one. Now committing works as expected.

我有同样的问题。在.git我想要创建新存储库的位置有一个现有存储库。我删除了它并创建了一个新的。现在提交按预期工作。

If you aren't sure if there might be an existing .gitat the target location of your repository, do this (on a Unix machine):

如果您不确定.git您的存储库的目标位置是否可能存在,请执行以下操作(在 Unix 机器上):

$> cd <path>
$> ls -aef 

This should show you the hidden files (like .git). Now you have two options: either delete the .gitdirectory

这应该会向您显示隐藏文件(如.git)。现在你有两个选择:要么删除.git目录

$> sudo rm -R .git

or change the owner rights.

或更改所有者权限。

回答by c0d3rman

This is a weird error.

这是一个奇怪的错误。

It seems to be a permissions error as indicated by git (command line), but persists even if permissions are 777.

这似乎是 git(命令行)所指示的权限错误,但即使权限为 777 仍然存在。

What worked for me was going into terminal, cding into the directory, and manually adding it to the index.

对我有用的是进入终端,cd进入目录,然后手动将其添加到索引中。

So you would do:

所以你会这样做:

cd <WHEREVER-YOUR-PROJECT-IS>/laravel-master/
sudo git add vendor/illuminate/remote/Illuminate/Remote/
sudo git add vendor/anahkiasen/rocketeer/

And then try the GitHub utility again.

然后再次尝试 GitHub 实用程序。

Let me know if it works!

让我知道它是否有效!

回答by LedsBringIt

This was annoying me for weeks! I had to keep going into terminal and adding each file and committing from the terminal which isnt as nice as using the app.

I finally contacted GitHub support and they advised me that they were aware of the issue and are releasing a fix soon.

这让我烦了好几个星期!我不得不继续进入终端并添加每个文件并从终端提交,这不像使用应用程序那么好。

我终于联系了 GitHub 支持,他们告诉我他们已经意识到这个问题并且很快就会发布修复程序。

Open up your terminal or shell and navigate to the repository and enter:

打开您的终端或外壳程序并导航到存储库并输入:

git config --local core.safecrlf false


This will disable the core.safeclrfproperty for the repository which is causing the issue.


这将禁用core.safeclrf导致问题的存储库的属性。

That should work :)

那应该工作:)

Note:I am using the Mac version of the GitHub app (A New Hope (180))

注意:我使用的是 Mac 版本的 GitHub 应用程序(新希望(180))

回答by LiweiZ

My silly way to resolve this is to copy every files I needed and deleted the folder, then created a new folder with the same name and copied them back. It actually worked for me. I'm new to github and don't know how to find out the previously existing git file (though I did know it was probably caused by conflict between old and new config files). It's better to learn how github works to use it as a tool better. But for now, if you want to have a quick solution, mine might work for you.

我解决这个问题的愚蠢方法是复制我需要的每个文件并删除该文件夹,然后创建一个具有相同名称的新文件夹并将它们复制回来。它实际上对我有用。我是 github 的新手,不知道如何找出以前存在的 git 文件(虽然我知道这可能是由新旧配置文件之间的冲突引起的)。最好学习 github 是如何工作的,以便更好地将其用作工具。但是现在,如果你想快速解决,我的可能适合你。

回答by Noah Labhart

Thought this might be work adding in here...

认为这可能是在这里添加的工作......

When I tried to commit my changes, I still had Xcode open. As such, the Github utility has issues adding files due to some security thing. I closed Xcode, but the error persisted in the Github utility. I had to close, and reopen the Github utility before it would work.

当我尝试提交更改时,我仍然打开了 Xcode。因此,由于某些安全问题,Github 实用程序在添加文件时存在问题。我关闭了 Xcode,但错误仍然存​​在于 Github 实用程序中。我不得不关闭并重新打开 Github 实用程序,然后它才能工作。

Food for thought!

深思熟虑!

回答by Frank Wang

In my case, I solved the problem by manually creating a new folder. For example, I want to move a folder named "echarts" into my github repo. I just created a folder with the name echarts, and then copy the files in echarts and paste to the folder. It involves no git script.

就我而言,我通过手动创建一个新文件夹来解决该问题。例如,我想将一个名为“echarts”的文件夹移动到我的 github 存储库中。我刚刚创建了一个名为echarts的文件夹,然后将echarts中的文件复制并粘贴到该文件夹​​中。它不涉及 git 脚本。

回答by Dhruv Ramani

There might be different causes for the problem. For me, the file permissions were changed.

问题可能有不同的原因。对我来说,文件权限已更改。

Run the following commands on the terminal :

在终端上运行以下命令:

$ cd <path>
$ chmod u+rw file.py

回答by not_this_again

A temporary workaround is to make a commit without the files that are causing the problem. Check the bad files off the commit list, do a local commit but don't push to the server, i.e. the button with circling arrows must notbe green. Then go to your IDE, copy the content of the classes/files somewhere, then delete the problematic file. Create a new file and paste. Restart the github app, then do a commit with these new ones and then you can push. Worked for me.

临时解决方法是在没有导致问题的文件的情况下进行提交。从提交列表中检查坏文件,进行本地提交但不要推送到服务器,即带有圆圈箭头的按钮不能为绿色。然后转到您的 IDE,将类/文件的内容复制到某处,然后删除有问题的文件。创建一个新文件并粘贴。重新启动 github 应用程序,然后使用这些新应用程序进行提交,然后您就可以推送了。对我来说有效。

I'm using v.185 (Responder Train).

我正在使用 v.185(响应火车)。

回答by Haggis19

Check to see if you have Xcode installed. There was a EULA agreement I needed to agree to before it would allow me to commit

检查您是否安装了 Xcode。在允许我承诺之前,我需要同意一个 EULA 协议