突然无法从 origin git fetch

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3736998/
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-19 04:35:25  来源:igfitidea点击:

Suddenly unable to git fetch from origin

gitgit-remote

提问by dublev

In my repository, I remotely track our main repository, which is bare. I've never had any problems with fetching from origin the past.

在我的存储库中,我远程跟踪我们的主存储库,它是空的。过去我从来没有遇到过从原点获取的问题。

However, when I tried to remote update this morning, I got the following error:

但是,当我今天早上尝试远程更新时,出现以下错误:

fatal: '/users/integrator/project' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
error: Could not fetch origin

I haven't changed anything, and the repository is definitely still there. There are several people who have access to the integrator account, but they generally do merges and pulls. We don't allow pushing to this repository.

我没有改变任何东西,存储库肯定还在那里。有几个人可以访问集成商帐户,但他们通常会进行合并和拉取。我们不允许推送到这个存储库。

My question is: what could have caused this to happen? Or, are there any diagnostics I can use to figure out what is going wrong? I am not the only user suddenly having this problem, so the problem is more likely on the side of origin.

我的问题是:什么可能导致这种情况发生?或者,是否有任何诊断方法可以用来找出问题所在?我不是唯一一个突然遇到这个问题的用户,所以问题更可能出在源端。

Update:

更新:

When I try to clone the bare repository, I get the following error:

当我尝试克隆裸存储库时,出现以下错误:

git clone /users/integrator/project
Cloning into project...
fatal: failed to open '/users/integrator/project/.git/objects': No such file or directory

Here's a list of the contents of /users/integrator/project:

以下是 /users/integrator/project 的内容列表:

config
HEAD
packed-refs
ssh_helper
bin/
hooks/
info/
  exclude
objects/
  [lots of folders with two character long names]
  info/
  pack/
refs/
  heads/
  tags/

回答by Brian Campbell

I would take a look at what is in the /users/integrator/projectdirectory on your server. Does it look like a git repository? It needs to have at leas an objectsdirectory, refsdirectory, and HEADfile in order to be a proper git repository. Does it contain all of those?

我会看看/users/integrator/project你服务器上的目录中有什么。它看起来像一个 git 存储库吗?它至少需要有一个objects目录、refs目录和HEAD文件才能成为一个合适的 git 存储库。它包含所有这些吗?

Another thing to check is if you can log in directly to the server, and clone from the repository.

要检查的另一件事是您是否可以直接登录到服务器,并从存储库中进行克隆。

Beyond that, if you still can't figure out what's wrong, I'd recommend editing your question to show a listing of what's in /users/integrator/project, and perhaps we can provide more help with that information.

除此之外,如果您仍然无法弄清楚出了什么问题,我建议您编辑您的问题以显示 中的内容列表/users/integrator/project,也许我们可以提供有关该信息的更多帮助。

editbased on your edit:

编辑根据您的修改:

Given the error, it looks like you might have a .gitdirectory within your bare repository. You can check with ls -a, to show hidden files as well. If this is the case, Git may be looking into the .gitdirectory within your repository first, instead of looking at your repository directory itself. I would take a look for that, and then move the inner .gitaway or delete it to allow Git to access your actual repository.

鉴于错误,.git您的裸存储库中似乎有一个目录。您也可以使用ls -a, 进行检查以显示隐藏文件。如果是这种情况,Git 可能会.git首先查看存储库中的目录,而不是查看存储库目录本身。我会看一下,然后将内部.git移走或删除它以允许 Git 访问您的实际存储库。

If there isn't a .gitdirectory within your repo, look around for anything named .gitor project.gitin the vicinity too; Git will search a variety of path names based on the one you give it, and a bare path name without a .gitsubdirectory or suffix is near the end of what it searches.

如果.git您的 repo 中没有目录,请四处寻找已命名.gitproject.git附近的任何内容;Git 将根据您提供的路径名搜索各种路径名,并且没有.git子目录或后缀的裸路径名接近搜索的结尾。