简体   繁体   English

致命:远程源已经存在

[英]Fatal: remote origin already exists

I'm taking a free, virtual Harvard CS course and am trying to submit a project: that is, a directory called "search."我正在参加免费的虚拟哈佛计算机科学课程,并尝试提交一个项目:即一个名为“搜索”的目录。 The instructions to submit are:提交说明如下:

git init
git remote add origin https://github.com/me50/USERNAME.git
git add -A
git commit -m "Submit project 0"
git push origin master:web50/projects/2020/x/search

When I do git init, I get当我执行 git init 时,我得到

Reinitialized existing Git repository in /Users/MYNAME/Desktop/CS50_WebDev/search/.git/

When I do git remote add origin https://github.com/me50/USERNAME.git , I get当我做 git remote add origin https://github.com/me50/USERNAME.git 时,我得到

fatal: remote origin already exists.

I've been trying to fix this problem for the last 3 hours.在过去的 3 个小时里,我一直在努力解决这个问题。 Please help me.请帮我。

The bot grading is very particular: "By way of example, for this project that means that if the grading staff visits https://github.com/me50/USERNAME/blob/web50/projects/2020/x/search/index.html (where USERNAME is your own GitHub username as provided in the form, below) your submission for index.html for this project should be what appears. If it doesn't, reorganize your repository as needed to match this paradigm.: bot 评分非常特别:“例如,对于这个项目,这意味着如果评分人员访问https://github.com/me50/USERNAME/blob/web50/projects/2020/x/search/index.html。 html (其中 USERNAME 是您自己的 GitHub 用户名,如下面的表单中提供的)您为此项目提交的 index.html 应该是显示的内容。如果没有,请根据需要重新组织您的存储库以匹配此范例。:

When I do git init, I get当我执行 git init 时,我得到

Reinitialized existing Git repository ...

This is the source of the error.这是错误的根源。 The instructions assume that you do not yet have a Git repository, so that git init will create one.这些说明假设您还没有 Git 存储库,因此git init创建一个。 If you already have a Git repository, git init mostly does nothing.如果您已经有一个 Git 存储库,则git init基本上什么都不做。 1 Hence if your existing Git repository already has a remote named origin , git remote add origin fails because it can't add a new origin. 1因此,如果您现有的 Git 存储库已经有一个名为origin的远程,则git remote add origin失败,因为它无法添加新的源。

Probably what you should be doing is starting in a new directory that does not have an existing Git repository.可能你应该做的是在一个没有现有 Git 存储库的新目录中开始。 (Usually I like to start with a completely empty directory, rather than one populated with some existing files, but their instructions assume you have a directory populated with files, just no .git hidden sub-directory.) (通常我喜欢从一个完全空的目录开始,而不是一个填充了一些现有文件的目录,但他们的说明假设您有一个填充了文件的目录,只是没有.git隐藏子目录。)


1 The mostly is here because it still installs any standard hooks from the standard-hook-template directory. 1主要在这里是因为它仍然从标准钩模板目录安装任何标准钩子。 You can use this to install particular Git hooks from a particular directory of your choice, using the --template option.您可以使用--template选项从您选择的特定目录安装特定的 Git 钩子。 I don't know of anyone who actually does this.我不知道有谁真正做到了这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM