我试图按照迈克尔哈特尔的Rails教程,但我遇到了一个错误。

我在GitHub注册了,发放了一个新的SSH密钥,并创建了一个新的存储库。但是当我在终端中输入下一行时,我得到了以下错误:

Parkers-MacBook-Pro:.ssh ppreyer$ git remote add origin git@github.com:ppreyer/first_app.git
fatal: remote origin already exists.

只是想知道是否有人遇到过这个问题?


当前回答

使用此命令更新已经存在的源

git remote set-url origin https://github.com/SriramUmapathy/ReduxLearning.git

其他回答

在Windows上使用git bash将存储库添加到git hun时遇到同样的错误

 git remote add origin https://github.com/axaysushir/netflix_page_clone.git

致命:远程源已经存在。

fatal: remote origin already exists.

 ! [rejected]        master -> master (fetch first)

错误:无法将一些引用推到“https://github.com/axaysushir/meditation_app_using_js.git”

通过以下命令更新存储库

$ git remote set-url origin https://github.com/axaysushir/netflix_page_clone.git

然后添加存储库使用git远程添加github而不是git远程添加起源

$ git remote add github https://github.com/axaysushir/netflix_page_clone.git

然后写以下命令,而不是git push origin master,这将把你的存储库上传到github

$ git push github master

试试这个

cd existing_repo Git远程重命名原点old-origin

git remote set-url origin https://username:PERSONAL_ACCESS_TOKEN@github.com:ppreyer/first_app.git
git push -u origin main

你可以在github上使用以下步骤生成个人访问令牌:

转到设置 点击开发者设置 单击Generate new token 生成您的个人访问令牌并将其粘贴到上面的命令上。:)

试试这个命令,对我有用。

Rm -rf .git/

如果你已经为另一个存储添加了项目,比如你上传到github,然后你上传到bitbucket,然后它会显示这种类型的错误。

如何删除错误:删除git-hub文件,然后重复以下步骤…

git init       
git remote add origin git@bitbucket.org:Yourname/firstdemotry.git  
git add -A  
git commit -m 'Message'  
git push -u origin master