Git 忘记了我从中获取/推送到的远程存储库
今天早上我去执行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以查看 .git/config 并配置它。
您还可以通过键入让本地分支跟踪远程分支
git 分支 --set-upstream;
当您输入
git fetch
时,本地分支将从那些跟踪远程分支中获取代码。You can take a look on .git/config and configure it.
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.似乎是一个很老的问题,但想更新一下 Kit Ho 的答案并稍加修改。可能对某人有用。
从 git 版本 1.9.2 开始已弃用。现在这是正确的语法,
一个例子是,
Seems like a very old question, but want to update to Kit Ho's answer with slight modification. Might be useful for someone.
is deprecated as of git version 1.9.2. This is the correct syntax now,
An example would be,
远程信息应存储在 .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...