"Commit failed - exit code 1 received" 尝试在 github 桌面上提交新的本地存储库时

"Commit failed - exit code 1 received" when trying to commit a new local reprository in gihub desktop

当我尝试从 GitHub-desktopGitHub 提交我的新本地存储库时正在抛出错误 "Commit failed - exit code 1 received"

关于:

首先检查您是否已将文件添加到索引中。
打开命令行并检查您的 git status.

其次,见desktop/desktop issue 3701

some users have run into this error due to having nested .git directories.
Can you try searching your repository to see if you have multiple .git directories?

Had a .git in my repository (which I needed) and a .git in a subfolder (which I deleted), then it worked.

最后,检查您是否有任何子模块(存储库根目录中的 .gitmodules 文件)。
参见 desktop/desktop issue 1770

If I commit changes in submodule myself than GitHub Desktop is able to push and/or commit changes after that. After submodule is committed manually SHA1 changes from dirty. At this point I can commit to main repo.

我从 GitHub 桌面(不是从磁盘)删除了存储库,然后再次将其添加为本地存储库,这为我解决了问题。

我也收到了这个错误,但与其他人不同的是,我没有任何嵌套的 .git 文件夹。尝试查看更改时,每个文件都显示为 "empty",直到我从 GitHub 桌面删除存储库并再次添加它。

提交时的退出代码 1 并不总是真实的 "error"。

我不知道 GitHub-desktop(以及 GitHub-desktop 确切执行哪些命令)但也许你的问题与我的问题具有相同的 core-"problem"几天前。 在我的例子中,我有一个分支 master tracks/follows origin/master。我执行了:

git pull --no-commit --no-ff
git commit -m "merge"

我发现如果 origin/master 没有可以被 git pull-command 提取的提交,那么 git commit-command 显然什么都不做,因为没有阶段性的变化和尽管没有发生错误,但有(imo:令人惊讶的)退出代码 1。

(我猜 git commit 应该有 exitcode 0 如果它真的创建了一个提交)。

我遇到了同样的事情,它是由子文件夹中的 .git 引起的。

刚刚删除了所有相关的 .git 文件,错误消失了。

已解决。 我通过 cmd 提示提交并且没有再遇到这个问题。