致命:没有配置推送目的地

use*_*866 22 git github

请参阅以下屏幕详细信息 - git remote -v命令显示我已添加test_vish,但是当我发出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]>
Run Code Online (Sandbox Code Playgroud)

joh*_*ton 18

试试这个:

git push -u github master

这将设置您的本地master分支以跟踪远程master分支github.

下次推送此分支时,您应该能够使用较短的命令git push.

  • 一次修复所有分支:git push -u github --all (2认同)

mic*_*has 8

你只是说git push没有告诉git要推送什么以及推送到哪里.因此git必须猜测你的意思.

推送的完整语法是:

git push <remote> <local_branch>:<remote_branch>
Run Code Online (Sandbox Code Playgroud)

例如

git push github master:master
Run Code Online (Sandbox Code Playgroud)

这会将当前主分支推送到github的主分支.

你可以省略零件,但是你需要知道剩下的零件默认是什么.(这些默认值在很大程度上取决于您的配置.)

在你的情况下你已经定义了两个遥控器"origin"和"github",但你没有告诉git它应该使用哪个遥控器.现在git默认为"origin"遥控器.不幸的是,没有为该遥控器定义推送URL,因此git没有办法推动它,并正确地抱怨它.

你可能想用

git push --set-upstream github master:master
Run Code Online (Sandbox Code Playgroud)

这告诉git将正确的东西推到正确的位置,并为本地分支设置正确的上游(请参阅参考资料git branch -vv).因此,后续推送将注意到此上游并默认为正确的值.


Nat*_*han 8

其他答案使用git push并要求始终指定其他参数。此解决方案为推送操作设置默认远程。该命令假定您始终希望使用origin远程名称。

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