git push origin master不起作用

Koh*_*shi 4 git github

虽然,我可以在本地提交我的更改,但我无法推动原始主人

我跑

$ git remote add origin git@github.com:username/test.git
Run Code Online (Sandbox Code Playgroud)

我明白了

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

我跑

$ git push -u origin master
Run Code Online (Sandbox Code Playgroud)

我明白了

ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

这有什么问题?

Sum*_*ngh 5

2路做到这一点
: -

 git remote set-url <name> <newurl>
Run Code Online (Sandbox Code Playgroud)

例:-

git remote set-url origin git@github.com:username/test.git
Run Code Online (Sandbox Code Playgroud)

第二: -

你需要做的是改变你的'origin'设置.你在你的项目根目录中编辑.git/config,它可能看起来像这样:

...
[remote "origin"]
url = git://user@dev.foo.com/git/repos/path
fetch = +refs/heads/*:refs/remotes/origin/*
...
Run Code Online (Sandbox Code Playgroud)

或者如果你的'遥控'实际上是本地的:

...
[remote "origin"]
url = /path/to/repos/on/this/machine
fetch = +refs/heads/*:refs/remotes/origin/*
...
Run Code Online (Sandbox Code Playgroud)

您需要做的就是使用您喜欢的编辑器编辑该文件,并将url =设置更改为新位置.假设新存储库已正确设置并且您的URL正确,您将很乐意在新的远程位置推送和拉出.


Dou*_*gal 2

您的配置文件中似乎有一个错误的条目origin

编辑存储库的.git/config文件以更改它;该格式是相当不言自明的,但如果您遇到问题,请发布其内容。