如何解决"致命:远程起源已存在".在'git remote add'?

Ale*_*lex 1 git

我想在我的USB记忆棒上创建一个git存储库.在棍子上,我使用该命令创建了一个裸git存储库

git init --bare MyRepo
Run Code Online (Sandbox Code Playgroud)

在笔记本电脑上的存储库(Ubuntu 14.04)中,我发出了以下命令

git init
git add .
git commit -m 'first commit'
git remote add origin /media/alexander/Stick/MyRepo
Run Code Online (Sandbox Code Playgroud)

并得到了错误

fatal: remote origin already exists.
Run Code Online (Sandbox Code Playgroud)

我刚刚在棒上成功创建了一个git repo而没有任何错误(当然使用不同的目录).现在我收到了这个错误.'git status'的输出是

On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)

出了什么问题?

Saj*_*han 11

首先删除遥控器origin,然后再次添加路径.

$ git remote rm origin
$ git remote add origin <repo-url> 
Run Code Online (Sandbox Code Playgroud)

另一种方法:设置origin's网址而不是添加.

$ git remote set-url origin <repo-url>
Run Code Online (Sandbox Code Playgroud)