【问题标题】:Repository already exists - or not?存储库已经存在 - 或不存在?
【发布时间】:2014-02-01 08:50:14
【问题描述】:

我必须承认,我对初始化 Git 完全感到困惑——尽管这并不是第一次。

我首先下载了原始 Git bash 并在C:\xampp\htdocs\something 创建了一个存储库something。同时,我在我的个人资料下创建了 something 存储库。我当时认为他们可能会联系在一起(在我登录后)——这种天真很快就会受到惩罚。

然后我意识到这个 Git bash 真的不喜欢我,所以我下载了标准的“Git for windows”。 我删除了C:\xampp\htdocs\something中的.git,我删除了存储库的在线版本。我还查看了 Documents\GitHub\something 文件夹,但它不存在。

但是,听起来我删除的不够多 - 看看:
那么 Git 还会在哪里存储有关现有存储库的数据呢?我会因此而不得不选择不同的名字吗? 我可以列出存储库以了解它发生的原因吗?

通过控制台初始化 repo(成功)

可能的解决方法是使用 Git shell 控制台:

cd C:\xampp\htdocs\something
git init
Initialized empty Git repository in C:/xampp/htdocs/rimedit/.git/

使用 GUI 应用推送(失败)

但是使用控制台是一种解决方法,而不是答案。此外,我仍然无法推动:

用控制台推送(也失败了)

为了尽可能让我生气,这是控制台在推送时抛出的内容:

remote: Repository not found.
fatal: repository 'https://github.com/Darker/rimedit.git/' not found

请注意,该错误与我在 GUI 应用程序中遇到的错误完全相反。

删除缓存

Git 将一些缓存数据和帐户信息存储在 %APPDATA%\GitHub\ (thanks Chris)。删除缓存并没有解决问题 - 似乎它可能是服务器端的。

终于有一个解决方案(不是答案)

控制台中的 Repository not found. 通过再次在服务器上创建存储库来简单地修复。在此之后,我会得到这个推送:

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Darker/rimedit.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

所以我想拉,但又报错:

 * [new branch]      master     -> git/master
You asked to pull from the remote 'git', but did not specify
a branch. Because this is not the default configured remote

所以,毕竟我找到了this post。我将配置编辑为如下所示:

[remote "git"]
  url = https://github.com/<account name>/<repo name>.git
  fetch = +refs/heads/*:refs/remotes/git/*

[branch "master"]
  remote = git
  merge = refs/heads/master

在此之后,我只需要pull readme.md 然后push 我的所有数据。

【问题讨论】:

  • 我也怀疑服务器有问题。此时你可能想contact GitHub support
  • 我确实联系过他们。我已经在等回复了。我与他们联系了一段时间 - 但他们不确定任何事情,所以这可能是一个错误。 git init 解决方案来自 github 支持。

标签: git github


【解决方案1】:

.git 是唯一带有 git 元数据的目录。因此,如果特定目录是具有.git 目录的某个目录的子目录,则它是某种 inside git 存储库。

也许有一些“Git for Windows”元数据可以识别以前存在的存储库。或者你仍然有带有 git 元数据文件的 .git 目录。

【讨论】:

  • 整个C: 的任何可搜索文件夹中都不存在.git 文件夹(我仔细搜索过)。我强烈怀疑 git GUI 应用程序已将其缓存在某处。
【解决方案2】:

在您的Documents\GitHub\ 中查找名为something 的目录。删除它,您应该可以上路了。

GitHub for Windows 也将信息保存在 %APPDATA%\GitHub\ 中,但这似乎与您的问题无关。

【讨论】:

  • 克里斯,我已经说过我查看了文档,但该文件夹不存在。这是第三段的最后一句话。
  • 您是否也尝试过删除%APPDATA% 中的文件夹?我无法重现您的问题,但其中的缓存文件可能是相关的。
  • 我会尝试这样做,现在我正在检查可能产生的影响。我想除了批评之外,我应该告诉你,你回答的第二部分似乎很有希望。
  • 删除缓存没有帮助。
猜你喜欢
  • 2010-11-16
  • 2018-09-01
  • 1970-01-01
  • 2012-02-02
  • 1970-01-01
  • 2021-04-08
  • 2022-11-10
  • 2021-10-06
  • 1970-01-01
相关资源
最近更新 更多