2014-09-21 83 views
4

有上如何改变push命令的参数,使处理来避免这个消息的相关问题:如何禁止“致命的:当前分支的上游分支与当前分支的名称不匹配”?

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

我感兴趣的是如何压制消息本身,没有改变我的本地/远程分支的名称或使用花式push命令。

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

[email protected]:~ git branch -vv 
branch-name abcd1234 [remote/origin/branch-name] last commit message 

现在我希望能够通过简单地键入git push推我COMMITED变化。当我这样做,我得到以下信息:

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

回答

9

较新的Git(V 1.9或更新版本)

git config --global push.default upstream 

年长的Git

git config --global push.default tracking 

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

的代名词只是做一旦你“git push”,它会将当前分支推送到它配置的上游。

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

+0

谢谢安德鲁,我进入那个命令,然后键入'git push'并得到相同的消息。 – arman 2014-09-21 22:52:21

+0

查看存储库.git/config文件或系统中是否存在冲突的设置/ etc/gitconfig – 2014-09-21 22:56:52

+0

tracking最好似乎是可疑的:列出的5个可能值是'current','matching', 'nothing','simple'和'upstream'。在这种情况下,“上游”似乎是最有可能的期望之一。跟踪和上游的 – torek 2014-09-22 00:32:35

相关问题