问题
When I create a new branch from a remote branch using EGit I get the wrong remote tracking set up:
I create the local branch feature1 from the remote branch refs/heads/master and immediately push to upstream. The followign remote tracking gets configured in my .git/config file:
[branch "feature1"]
remote = origin
merge = refs/heads/master
So, pull and push in that branch will pull and pull from/to the remote master branch. I would expect the following tracking configuration instead:
[branch "feature1"]
remote = origin
merge = refs/heads/feature1
I know I can fix it even from EGit, but I'm worried about other developers in my team not realizing this and pushing uncompleted features to the master branch.
Am I doing something wrong?
回答1:
Maybe you should advise developers to create feature-branches not from the remote-tracking branch (e.g. origin/master), but from the local one (master). This way, EGit will not set up any remote tracking by default.
If you then decide to publish the branch for the first time, it should be possible to set up the remote tracking (the equivalent of git push --set-upstream) after bug 378960 is implemented.
回答2:
Egit will, by default, take the upstream branch for the merge parameter when creating a branch from a remote one.
That means, if you want to enforce the policy which is to push to remote/master
only from a local branch master
, you can try and enforce it locally.
Check if Egit respects a git config push.default current
for pushing only the current branch to an upstream branch with the same name (which might actually become the default policy after git1.7.10).
However, that has the issue of making sure every developer has that policy active in his/her repo.
(I don't think you can enforce it at the "central" repo one, where you could add a server-side hook like an update
hook: that script take the name of the branch being updated (ie here 'master
', not the name of the branch in the downstream repo, ie here 'feature1
')
Note: bug 378960 has been marked as resolved (February 2014) in Egit 3.2:
Push Branch / Initial Push wizard simplifies pushing a branch and also allows upstream configuration for new branches created by the push operation:
来源:https://stackoverflow.com/questions/10539450/egit-set-up-remote-tracking-correctly-when-creating-a-branch