如何抑制“致命:当前分支的上游分支与当前分支的名称不匹配”?

时间:2014-09-21 22:34:57

标签: git

有关SO的相关问题涉及如何更改push命令的参数以避免此消息:

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

我对如何压制邮件本身感兴趣,没有更改本地/远程分支的名称或使用花哨的push命令。

假设我有一个本地分支跟踪一个不同名称的远程分支:

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

现在,我希望只需输入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:remote/origin/branch-name

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

    git push origin branch-name

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

1 个答案:

答案 0 :(得分:9)

Newer Git(v 1.9或更新版)

git config --global push.default upstream

年长的Git

git config --global push.default tracking

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

只要做一次,只要你" git push"它会将您当前的分支推送到其配置的上游。

这也会在您的全局配置中设置它,可能会被存储库配置中的其他设置所遮蔽。