'fatal: No destination configure to push to' 错误当我执行'git push'

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

‘fatal: No destination configured to push to’ error when I do a 'git push'

git

提问by michael

I try to checkout a remote branch.

我尝试结帐远程分支。

And then make a commit and then push.

然后进行提交,然后推送。

I get fatal: No destination configured to push toerror when I do a 'git push'.

我得到的fatal: No destination configured to push to错误,当我做了“混帐推”。

Here is the sequence of commands I use:

这是我使用的命令序列:

$ git checkout remote/test-1.6
$ git checkout -b test-1.6
$ git commit -a -m "commit message"
$ git push
fatal: No destination configured to push to.

Thank you.

谢谢你。

采纳答案by John Lyon

You need to specify both the remote alias and the branch you wish to push (if there are many branches and you only want to push one).

您需要指定远程别名和要推送的分支(如果有很多分支而您只想推送一个)。

From the docs for push:

来自push 的文档

[to commit to a remote repo] you run git push [alias] [branch]which will attempt to make your [branch] the new [branch] on the [alias] remote.

[提交到远程存储库] 您运行git push [alias] [branch]这将尝试使您的 [branch] 成为 [alias] 远程上的新 [branch]。

If you wish to push all branches to the remote repo (or only have one to push), you can omit the branch specifier and do a

如果您希望将所有分支推送到远程仓库(或只有一个要推送),您可以省略分支说明符并执行

git push [alias]

For your specific case, as Mike specified in his comment,

对于您的具体情况,正如迈克在评论中指出的那样,

git push remote test-1.6

should work.

应该管用。

回答by yoyo

You probably already have a remote for your repository, but your new branch hasn't been configured to use it. This should work:

您可能已经有一个远程存储库,但您的新分支尚未配置为使用它。这应该有效:

git push --set-upstream remote test-1.6

Having done that once, there is now a tracking branch in place and you can simply use "git push" in future -- assuming you've configured upstream push of the current branch as the default, like so:

完成一次后,现在有一个跟踪分支,您可以在将来简单地使用“git push”——假设您已将当前分支的上游推送配置为默认值,如下所示:

git config --global push.default tracking

Or (preferred) as of git 1.7.4:

或者(首选)从 git 1.7.4 开始:

git config --global push.default upstream

回答by ben

try to add a remote repo with

尝试添加远程仓库

git remote add remote http://.../repo.git

then you can do a

那么你可以做一个

git push remote test-1.6

回答by Genjuro

right you have to first add a remote

对,你得先加个遥控器

git remote add myremote  [url]

then you will be able to push using : git push myremote master(or any other branch)

然后你就可以使用 : git push myremote master( 或任何其他分支)