git pull 生成“致命:未指定远程存储库”。错误

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

git pull generates "fatal: No remote repository specified." error

gitgithub

提问by Falk

I want to start contributing to a project hosted on Github. I have taken the following steps:

我想开始为 Github 上托管的项目做贡献。我采取了以下步骤:

  1. git init
  2. git pull https://github.com/PrincetonUniversity/EVCM.git
  1. 混帐初始化
  2. git pull https://github.com/PrincetonUniversity/EVCM.git

The pull command succeeded and the files where copied to my local directory. But when I try git pull again, then I get the following error

pull 命令成功并将文件复制到我的本地目录。但是当我再次尝试 git pull 时,我收到以下错误

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

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

I did not get this error when I pulled from and pushed to other Github repositories in the past. What is the problem and how can I fix it? Could it be because I have pulled the same repository to a different local directory in the past? In either case, what should I do to fix the problem?

过去,当我从其他 Github 存储库中提取并推送到其他 Github 存储库时,我没有收到此错误。有什么问题,我该如何解决?可能是因为我过去曾将同一个存储库拉到不同的本地目录?在这两种情况下,我应该怎么做才能解决问题?

回答by Perfect

You need to follow the correct steps.

您需要遵循正确的步骤。

You already did git init, then add remote by doing this.

你已经做了git init,然后通过这样做添加远程。

git remote add origin https://github.com/PrincetonUniversity/EVCM.git

Now the working tree can recognize originso

现在工作树可以识别origin等等

git pull origin master

That's all and I hope it would be helpful to you.

这就是全部,我希望它对您有所帮助。

Thanks

谢谢

回答by Eric Brandwein

You should always start with a git clone(and I'd suggest you do that), but if you want to continue from here, here's the way:

您应该始终以 a 开头git clone(我建议您这样做),但如果您想从这里继续,方法如下:

You can use git remote add origin https://github.com/PrincetonUniversity/EVCM.gitto add a remote, and set its name to origin. You can check this tutorialif you want to know more. This, I hope, will fix your problem. If you encounter other problems, just do a git clone.

您可以使用git remote add origin https://github.com/PrincetonUniversity/EVCM.git来添加遥控器,并将其名称设置为origin. 如果您想了解更多信息,可以查看本教程。我希望这会解决您的问题。如果您遇到其他问题,只需执行git clone.

回答by Mingsheng

According to git's command line:

根据 git 的命令行:

If you wish to set tracking information for this branch you can do so with:

如果您希望为此分支设置跟踪信息,您可以这样做:

git branch --set-upstream-to=<remote>/<branch> <local branch>

This would allow you to simply run "git pull"instead of "git pull origin branch"

这将允许您简单地运行“git pull”而不是“git pull origin branch”

回答by Habib Kazemi

first do git remote add origin https://github.com/PrincetonUniversity/EVCM.git

先做 git remote add origin https://github.com/PrincetonUniversity/EVCM.git

then do git pull originhere is a good tutorial https://www.atlassian.com/git/tutorials/syncing/git-pull

然后在git pull origin这里做一个很好的教程https://www.atlassian.com/git/tutorials/syncing/git-pull

but if you use git clone it will create automatically the originfor you.

但是如果你使用 git clone 它会自动origin为你创建。