git push origin master 不起作用

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

git push origin master does not work

gitgithub

提问by Koh Takahashi

Although, I could commit my change locally, I can not push to origin master

虽然,我可以在本地提交我的更改,但我无法推送到 origin master

I run

我跑

$ git remote add origin [email protected]:username/test.git

I get

我得到

fatal: remote origin already exists.

I run

我跑

$ git push -u origin master

I get

我得到

ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

What's wrong with this?

这有什么问题?

回答by Sumit Singh

2-way to do this
1st:-

2-方法来做到这一点
: -

 git remote set-url <name> <newurl>

example:-

例子:-

git remote set-url origin [email protected]:username/test.git

2nd:-

第二:-

What you need to do is change your 'origin' setting.you edit .git/config in your project root, which may look something like this:

您需要做的是更改您的“原点”设置。您在项目根目录中编辑 .git/config,它可能如下所示:

...
[remote "origin"]
url = git://[email protected]/git/repos/path
fetch = +refs/heads/*:refs/remotes/origin/*
...

or if your 'remote' is actually local:

或者如果您的“遥控器”实际上是本地的:

...
[remote "origin"]
url = /path/to/repos/on/this/machine
fetch = +refs/heads/*:refs/remotes/origin/*
...

All you need to do is edit that file with your favorite editor and change the url = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll be happily pushing and pulling to and from your new remote location.

您需要做的就是使用您喜欢的编辑器编辑该文件并将 url = 设置更改为您的新位置。假设新存储库已正确设置并且您的 URL 正确,您将很高兴在新的远程位置进行推送和拉取操作。

回答by Dougal

It looks like there's a bad entry for originin your config file.

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

Edit your repository's .git/configfile to change it; the format is fairly self-explanatory, but post its contents if you have trouble.

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