git 致命:未配置推送目标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21072687/
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
fatal: No configured push destination
提问by user3186866
Please see following screen details - git remote -v command is showing that I have test_vishwas added but when I am giving Push command it is giving error. Anybody can help ?
请参阅以下屏幕详细信息 - git remote -v 命令显示我添加了 test_vishwas,但是当我给出 Push 命令时,它给出了错误。有人可以帮忙吗?
C:\Users\vishwas_gupta03\Documents\GitHub\test_Vishwas [master]> git remote -v
github https://github.com/vishwasjione/test_Vishwas.git (fetch)
github https://github.com/vishwasjione/test_Vishwas.git (push)
origin
C:\Users\vishwas_gupta03\Documents\GitHub\test_Vishwas [master]> git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository us
ing
git remote add <name> <url>
and then push using the remote name
git push <name>
C:\Users\vishwas_gupta03\Documents\GitHub\test_Vishwas [master]>
回答by johndbritton
Try this:
尝试这个:
git push -u github master
git push -u github master
This will set your local master
branch to track the master
branch on the github
remote.
这将设置您的本地master
分支以跟踪远程master
分支github
。
Next time you push this branch, you should be able to use the shorter command git push
.
下次推送此分支时,您应该可以使用较短的命令git push
。
回答by michas
You just said git push
without telling git what to push and where to push to. Therefore git has to guesswhat you mean.
你只是说git push
没有告诉 git 推送什么以及推送到哪里。因此 git 必须猜测你的意思。
The complete syntax for a push is:
推送的完整语法是:
git push <remote> <local_branch>:<remote_branch>
for example
例如
git push github master:master
which will push the current master branch to the master branch at github.
这会将当前的 master 分支推送到 github 的 master 分支。
You are allowed to leave out parts, but then you need to have a good idea what the left out parts default to. (Those defaults depend heavily on you configuration.)
您可以省略部分,但随后您需要很好地了解所省略部分的默认值。(这些默认值在很大程度上取决于您的配置。)
In your case you have defined two remotes "origin" and "github", but you did not tell git which remote it should use. Now git default to the "origin" remote. Unfortunately there is no push URL defined for that remote, hence git has no way to push to it and rightly complains about it.
在您的情况下,您已经定义了两个遥控器“origin”和“github”,但是您没有告诉 git 它应该使用哪个遥控器。现在 git 默认为“origin”远程。不幸的是,没有为那个远程定义推送 URL,因此 git 无法推送到它,并且正确地抱怨它。
You probably want to use
你可能想用
git push --set-upstream github master:master
This tells git to push the right thing to the right place and also sets the correct upstream for your local branch (see git branch -vv
). Therfore a subsequent push will notice this upstream and default to the correct values.
这告诉 git 将正确的内容推送到正确的位置,并为您的本地分支设置正确的上游(请参阅 参考资料git branch -vv
)。因此,后续推送会注意到上游并默认为正确的值。
回答by Nathan
The other answers use git push
and require always specifying additional parameters. This solution sets the default remote for the push operation. The command assumes you always want to use origin
for the remote name.
其他答案使用git push
并要求始终指定其他参数。此解决方案为推送操作设置默认远程。该命令假定您始终希望使用origin
远程名称。
git remote add origin [email protected]:.../...git
回答by Parth
The command (or the URL in it) to add the github repository as a remote isn't quite correct. If I understand your repository name correctly, it should be;
将 github 存储库添加为远程的命令(或其中的 URL)不太正确。如果我正确理解了您的存储库名称,则应该是;
git remote add my_app '[email protected]:userName/my_app.git'
Now run this command
现在运行这个命令
git push --set-upstream new master