Git返回错误:401(curl_result = 22,http_code = 401,sha1 =

时间:2013-06-23 18:57:08

标签: git

自从我升级到ubuntu 12.04后,我不明白为什么命令git pull origin master停止工作我的电脑。该命令适用于所有其他计算机和服务器。这是我在电脑上做的事情:

mkdir gittest
cd gittest
git init
git remote add origin http://johnuser@git.mywebsite.com/websiteproject
git pull origin master

我被提示输入密码。所以我给出了正确的密码。但是我个人的ubuntu 12.04,我收到了这个错误:

error: The requested URL returned error: 401 (curl_result = 22, http_code = 401, sha1 = d32f1e47321f14d4391168f7b26ce37f0b585803)
error: Unable to find d32f1e47321f14d4391168f7b26ce37f0b585803 under http://johnuser@git.mywebsite.com/websiteproject
Cannot obtain needed blob d32f1e47321f14d4391168f7b26ce37f0b585803
while processing commit eba6849896d12c9652bbc75ffcbc36ab2fc9a847.
error: Fetch failed.

我查看了git.mywebsite.com/log/error.log,我看到以下错误:

[Sun Jun 23 13:43:00 2013] [error] [client 11.11.11.11] user johnuser: authentication failure for "/websiteproject/objects/cf/fe85cd3a4af8f2cced2bdddbaed72f150ec568": Password Mismatch

如上所述,我从任何其他计算机(macs,windows,linux等)都没有问题。我尝试运行git gc和git update-server-info。但同样的错误导致了我的个人电脑。

发生了什么事?

其他信息:从https://github.com/abraham/twitteroauth.git等其他服务器的网址中执行git pull我没有问题。所以这似乎是我的服务器和我的电脑特有的东西。

附加信息2:好的,如果我的原始网址为http://johnuser:mypassword@git.mywebsite.com/websiteproject,我可以执行git pull。但是现在当我尝试git push时,终端会挂起大约15分钟,然后再向我显示以下错误:

Unable to refresh lock for http://johnuser:mypassword@git.mywebsite.com/websiteproject/info/refs
LOCK HTTP error 412

我查看了apache错误日志,看到了:

[Sun Jun 23 14:26:36 2013] [error] [client 11.11.11.11] (2)No such file or directory: The precondition(s) specified by the "If:" header did not match this resource. At least one failure is because: a State-token was supplied, but it was not found in the locks on this resource.  [412, #0]
[Sun Jun 23 14:26:36 2013] [error] [client 11.11.11.11] Could not LOCK /websiteproject/info/refs due to a failed precondition (e.g. other locks).  [412, #0]

1 个答案:

答案 0 :(得分:1)

好的,我解决了这个问题。

我做的第一件事就是将远程网址从http://johnuser@git.mywebsite.com/websiteproject更改为http://johnuser:mypassword@git.mywebsite.com/websiteproject。就这样,我把密码放在我的网址上。

这解决了我的git pull问题。但是,我开始将412锁定。为了解决这个问题,在我的计算机上,我使用以下内容创建了文件~/.netrc-file

machine git.mywebsite.com
login johnuser
password mypassword

然后我能够做一个git push。