我有几个分支:master
,develop
,feature1
,feature2
。
我在feature1
和feature2
(已推送)中开发了一些内容。然后我切换到master
,做了一些修改并推了推:
% git push
To git@github.acme.com:ossmgt/myrepo.git
! [rejected] feature1 -> feature1 (non-fast-forward)
! [rejected] feature2 -> feature2 (non-fast-forward)
error: failed to push some refs to 'git@github.acme.com:ossmgt/myrepo.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration
hint: variable to 'current' or 'upstream' to push only the current branch.
我已经在我们的本地ACME Github实例上验证了对master
的更改被推送。但git似乎有一个想法,一旦我推到feature1
和feature2
我仍然想要推动那些分支,即使我切换到另一个分支,例如master
。配置:
% git remote show origin
* remote origin
Fetch URL: git@github.acme.com:ossmgt/myrepo.git
Push URL: git@github.acme.com:ossmgt/myrepo.git
HEAD branch: master
Remote branches:
develop tracked
master tracked
feature1 tracked
feature2 tracked
Local branches configured for 'git pull':
master merges with remote master
feature1 merges with remote feature1
feature2 merges with remote feature2
Local refs configured for 'git push':
develop pushes to develop (up to date)
master pushes to master (up to date)
feature1 pushes to feature1 (local out of date)
feature2 pushes to feature2 (local out of date)
这似乎是无害的,但它很烦人。如何配置git以仅推送到CURRENT(签出)分支?
答案 0 :(得分:2)
我认为你在寻找的是:
git config --global push.default current
这会将git配置为仅推送当前分支。 有关详细信息,请参阅http://git-scm.com/docs/git-config。