Git 忘记了我从中获取/推送到的远程存储库

发布于 2024-11-27 18:59:05 字数 554 浏览 0 评论 0原文

今天早上我去执行 git fetch 并收到以下错误:

致命:未指定远程存储库。请指定一个 URL 或应从中获取新修订的远程名称。

这曾经工作得很好。看起来 git 忘记了我的(所有)分支和存储库之间的链接。
输入 git remote -v 不会返回任何内容。
它在上周末就开始工作了,我能想到的唯一改变就是安装最新的 GitExtensions 版本。然而现在我更担心是否有某种方法可以取回存储库信息。
有什么想法吗?

更新:
我的 .git/config 文件是空的。虽然我不知道原因,但我能够远程桌面到公司的另一台计算机并检索其配置的“远程”部分。
我已经更新了我的配置文件,到目前为止它看起来正在工作:-)

更新 2: 我还需要通过以下方式将分支重新链接到原点:

git config branch.develop.remote origin
git config branch.develop.merge refs/heads/develop

This morning I went to do a git fetch and got the following error:

fatal: No remote repository specified. Please, specify either a URL
or a remote name from which new revisions should be fetched.

This used to work fine. It looks like git has forgotten the link between (all) my branches and the repository.
Typing git remote -v doesn't return anything.
It was working at the end of last week, and the only thing that I can think of that I have changed was installing the latest GitExtensions release. However right now I am more worried about whether there is some way I can get back the repository information.
Any ideas?

Update:
My .git/config file was empty. Although I don't know the cause, I was able to remote desktop to another computer in the company and retrieve the "remote" section of its config.
I have updated my config file, and so far it looks like it is working :-)

Update 2:
I have also needed to relink the branches to the origin via:

git config branch.develop.remote origin
git config branch.develop.merge refs/heads/develop

etc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

私藏温柔 2024-12-04 18:59:05
  1. 您可以查看 .git/config 并配置它。

  2. 您还可以通过键入让本地分支跟踪远程分支

    git 分支 --set-upstream;

当您输入 git fetch 时,本地分支将从那些跟踪远程分支中获取代码。

  1. You can take a look on .git/config and configure it.

  2. You can also make your local branch track back your remote branch by typing

    git branch --set-upstream <localbranch> <remotebranch>

When you type git fetch the local branch will fetch codes from those tracking remote branch.

稳稳的幸福 2024-12-04 18:59:05

似乎是一个很老的问题,但想更新一下 Kit Ho 的答案并稍加修改。可能对某人有用。

git branch --set-upstream <localbranch> <remotebranch> 

从 git 版本 1.9.2 开始已弃用。现在这是正确的语法,

git branch --set-upstream-to=<upstream>

一个例子是,

git branch --set-upstream-to=originremote/testbranch

Seems like a very old question, but want to update to Kit Ho's answer with slight modification. Might be useful for someone.

git branch --set-upstream <localbranch> <remotebranch> 

is deprecated as of git version 1.9.2. This is the correct syntax now,

git branch --set-upstream-to=<upstream>

An example would be,

git branch --set-upstream-to=originremote/testbranch
伤痕我心 2024-12-04 18:59:05

远程信息应存储在 .git/config 文件中,检查该文件并查看它是否已损坏。如果是,您可能必须重新添加之前拥有的每个遥控器或进行彻底的检查,如果存在,则 GitExtension 版本中可能存在错误...

Remote information should be stored in the .git/config file, check that file and see if it's corrupted. If it is you might have to re-add every remote you had before or do a clean checkout, if it is there, there might be a bug in the GitExtension release...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文