git跟踪不同名称的分支 [英] git track branch with different name

查看:98
本文介绍了git跟踪不同名称的分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个跟踪非默认分支的回购。所以,有一个名为master的本地分支应该跟踪origin / master-13.07。我已经完成了推-u,我相信它应该足够了,分支被跟踪。 git分支的输出
$ b \repo> git branch -vv
stuff 68792df [origin / stuff-13.07]小错误修正
* master 68792df [origin / master-13.07:ahead 1]小错误修正
>
$ b'pre> C:\work\repo> git的状态
#的分支主
#你的分支的 '原点/主13.07' 通过提前1提交。
#(使用git push发布你的本地提交)

没有提交,工作目录干净

一切似乎都没错,但是当我使用git push(正如git推荐给我的那样)时,它会失败:

  C:\work\repo> GIT中推
致命:您的当前分支的上游分支不匹配
将当前分支的名称。推向上游分支
上的遥控器,使用

GIT中推原点HEAD:主 - 13.07

要推到相同的名称的对分支远程使用

git push origin master

是的,我知道名称不匹配,这正是我想要的,并且我通过push -u告诉了这样的混帐。为什么不能只使用 推送



  C:?\work\repo> GIT中--version 
git version 1.8.3.msysgit.0

C:\ work \ repo> git config push.default
simple


解决方案

好的。根据您添加的信息,我认为您只需将 push.default 更改为值上游



您可能在升级Git并看到以下消息后配置了实际值:

 警告:push.default未设置;它的隐含价值在
Git 2.0中从匹配变为简单。要压制此消息
并在默认更改后维护当前行为,请使用:

git config --global push.default匹配

若要压制此消息并现在采用新的行为,使用:

git config --global push.default simple

根据文档,当分支名称不同时,值 simple 必须拒绝推送。请参阅 Git配置(搜索 push.default )。


I have a repo which tracks non-default branches. So, there is a local branch named "master" which should track "origin/master-13.07". I've done "push -u", and I believe it should be enough, the branch is tracked. Output of the git branch -vv:

C:\work\repo>git branch -vv
  stuff     68792df [origin/stuff-13.07] Small bugfix
* master 68792df [origin/master-13.07: ahead 1] Small bugfix

Output of the git status

C:\work\repo>git status
# On branch master
# Your branch is ahead of 'origin/master-13.07' by 1 commit.
#   (use "git push" to publish your local commits)
#
nothing to commit, working directory clean

All seems all right, but when I just use "git push" (as git recommends me above), it fails:

C:\work\repo>git push
fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:master-13.07

To push to the branch of the same name on the remote, use

    git push origin master

Yes, I know that the name doesn't match, this is exactly what I want and I told so to git by "push -u". Why I cannot just use "push"?

C:\work\repo>git --version
git version 1.8.3.msysgit.0

C:\work\repo>git config push.default
simple

解决方案

Ok. With the informations you added, I think you simply have to change push.default to value upstream.

You probably configured the actual value after upgrading Git and seeing this message :

warning: push.default is unset; its implicit value is changing in 
Git 2.0 from 'matching' to 'simple'. To squelch this message 
and maintain the current behavior after the default changes, use: 

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use: 

  git config --global push.default simple

According to the documentation, value simple must reject a push when branch names are different. See Git Config (search for push.default).

这篇关于git跟踪不同名称的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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