Git错误:无法提交配置文件 [英] Git error: could not commit config file

查看:726
本文介绍了Git错误:无法提交配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为现有项目添加一个新的远程存储库(GitHub),而且我收到了一个我从未见过的错误,并且不明白:

I'm trying to add a new remote repository (GitHub) to an existing project, and I'm getting an error that I've never seen before, and don't understand:

$ git remote add github git@github.com:me/myrepo.git   
error: could not commit config file .git/config

什么?为什么我会提交git配置文件?我该如何让这种停止发生?

What? Why would I commit the git config file? And how do I make this stop happening?

我在Mac上,安装了大部分工具。我认为这是我第一次试图在这台机器上添加远程到repo。

I'm on a Mac, with a relatively fresh install of most of my tools. I think this is the first time I've tried to add a remote to a repo on this machine.

推荐答案

一些git命令修改git配置文件。其中之一是 git remote add ,因为远程存储在配置文件中。

Some git commands modify the git config file. One of them is git remote add, because the remote is stored in the config file.

为了避免出现问题几个git进程同时修改配置文件,git会在修改配置文件(通过编写锁定文件)之前锁定配置文件,然后释放锁定(通过将锁定文件重命名为配置文件)。

To avoid problems with several git processes modifying the config file simultaneously, git will lock the config file before changing it (by writing a lock file), and release the lock afterwards (by renaming the lock file to the config file).

错误信息

The error message

error: could not commit config file .git/config

表示git无法正确释放此锁。这可能意味着要么另一个进程在同一个文件上工作,要么出现某种文件系统错误(或者在git或OS /库中存在错误)。

means that git could not properly release this lock. This probably means that either another process was working on the same file, or there was some kind of filesystem error (or there's a bug in git or your OS/libraries).

不幸的是,git并没有告诉你问题到底是什么,所以你必须手动调试它。您可以尝试使用 dtruss ,看看到底发生了什么问题。

Unfortunately, git does not tell you what exactly was the problem, so you'll have to manually debug this. You could try running git with dtruss to see what exactly is going wrong.

这篇关于Git错误:无法提交配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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