如何在没有--set-upstream的情况下推送远程服务器上不存在的新分支? [英] How to push a new branch non-existing on the remote server without --set-upstream?

查看:275
本文介绍了如何在没有--set-upstream的情况下推送远程服务器上不存在的新分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这种情况是,我没有在远程服务器上重复使用,只是一个帐户。然后,我在本地运行以下命令,其中 x 是用户名, y 是仅存在于本地系统上的项目名称。

  git init 
git remote add buckety https://x@bitbucket.org/x/y.git
git add。
git commit --message我们去...
git push buckety

现在我收到错误的消息,敦促我设置远程上游。我可以做到这一点(无论是 - set-upstream -u ),但根据我的googlearching,它已被弃用。 (实际上很奇怪,控制台中的提示仍然提到它。)



我想以正确的方式做到这一点,并且我已经使用了 - track - set-upstream-to 。然而,就我所见到的Git而言,我没有特别的例子,我测试过的操作失败了。



我应该如何创建远程分支回缩到使用弃用的选项?我可能想要在远程创建一个跟踪分支,以便:


  1. 本地分支A对应于远程分支A,而且

    li>
  2. 本地分支A对应于远程分支B.

优选地,我想将它配置为之前,但我不知道如何。我无法使用结帐,因为分支尚不存在。我不能使用 set-upstream-to 出于同样的原因。 正确的命令是:

  git push -u origin master 

然后下一个git push会很简单: git push

请参阅为什么我需要显式推送新分支?



自从Git 1.8 - set-upstream 被称为 - set-upstream-to



您可以提前设置一个远程追踪分支

  git branch  - 你的第一个git push将是一个简单的 git push 


The scenario is that I have no repos on the remote server, just an account. Then, I run locally the following commands, where x is the user name and y is the project name that only exists on my local system.

git init  
git remote add buckety https://x@bitbucket.org/x/y.git  
git add .  
git commit --message "Here we go..."  
git push buckety

Now I get the error urging me to set up the remote upstream. I can do that (either --set-upstream or -u) but according to my googlearching, it's been deprecated. (Actually weird that the suggestion in the console mentions it still.)

I want to do it the proper way and I've goolearched both --track and --set-upstream-to. However, there's no example for my particular scenario on Git as far I could see and the operations I've tested failed with errors.

How should I create the remote branch without retracting to using the deprecated option? I might want to create a tracking branch on remote so that:

  1. the local branch A corresponds to the remote branch A, but also
  2. the local branch A corresponds to the remote branch B.

Preferably, I'd like to configure it prior to the push but I'm not sure how. I can't use checkout because the branch doesn't exist yet. I can't use set-upstream-to for the same reason.

解决方案

The right command is:

git push -u origin master

Then the next git push will be a simple: git push.

See "Why do I need to explicitly push a new branch?"

Since Git 1.8, --set-upstream is called --set-upstream-to

You can setup a remote tracking branch in advance with:

git branch -u origin/master master 

(Then your first git push would have been a simple git push)

这篇关于如何在没有--set-upstream的情况下推送远程服务器上不存在的新分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆