我该如何压制“致命的:当前分支的上游分支与当前分支的名称不匹配”? [英] How do I squelch "fatal: The upstream branch of your current branch does not match the name of your current branch"?

查看:1004
本文介绍了我该如何压制“致命的:当前分支的上游分支与当前分支的名称不匹配”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SO处理如何更改 push 命令的参数以避免此消息存在相关问题:

致命:当前分支的上游分支与当前分支的名称不匹配



我对如何压制消息本身感兴趣 p>假设我有一个本地分支跟踪一个不同名字的远程分支:

  user @ home:〜git branch -vv 
分支名称abcd1234 [remote / origin / branch-name]上次提交消息

现在我希望能够通过简单地输入 git push 来推送我提交的更改。当我这样做时,我收到以下消息:


 致命:当前的上游分支分支不匹配
当前分支的名称。要推送到远程的上游分支
,请使用

git push origin HEAD:remote / origin / branch-name

要推送到分支使用

git push origin branch-name


即使名称不匹配,我如何强制 git 自动推送到上游分支?我使用 git 1.9.1

解决方案

1.9或更新版本)

  git config --global push.default上游

旧版Git

  git config --global push.default跟踪

Git 2.3仍然接受跟踪作为上游的同义词



只要做到这一点,只要你git push,它就会将你当前的分支推送到配置好的上游。



这也将其设置在您的全局配置中,这可能会影响到您的存储库配置中的其他设置。


There is a related question on SO dealing with how to change the parameters of the push command to avoid this message:

fatal: The upstream branch of your current branch does not match the name of your current branch

I'm interested in how to squelch the message itself, without changing the names of my local/remote branches or using fancy push commands.

Suppose I have a local branch tracking a remote branch of a different name:

user@home:~ git branch -vv
branch-name abcd1234 [remote/origin/branch-name] last commit message

Now I want to be able to push my commited changes by simply typing git push. When I do this, I get the following message:

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:remote/origin/branch-name

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

    git push origin branch-name

How do I force git to automatically push to the upstream branch even if the names don't match? I'm using git 1.9.1

解决方案

Newer Git (v 1.9 or newer)

git config --global push.default upstream

Older Git

git config --global push.default tracking

Git 2.3 still accepts tracking as a synonym for upstream

Just do that once and whenever you "git push" it will push your current branch to its configured upstream.

This also sets it in your global config, which might be shadowed by a different setting in your repository config.

这篇关于我该如何压制“致命的:当前分支的上游分支与当前分支的名称不匹配”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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