简体   繁体   English

EGit - 在创建分支时正确设置远程跟踪

[英]EGit - set up remote tracking correctly when creating a branch

When I create a new branch from a remote branch using EGit I get the wrong remote tracking set up: 当我使用EGit从远程分支创建新分支时,我得到了错误的远程跟踪设置:

I create the local branch feature1 from the remote branch refs/heads/master and immediately push to upstream. 我从远程分支refs / heads / master创建本地分支feature1并立即推送到上游。 The followign remote tracking gets configured in my .git/config file: 在我的.git / config文件中配置了followign远程跟踪:

[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. 我知道我甚至可以从EGit修复它,但我担心我的团队中的其他开发人员没有意识到这一点并将未完成的功能推送到主分支。

Am I doing something wrong? 难道我做错了什么?

Egit will, by default, take the upstream branch for the merge parameter when creating a branch from a remote one. 默认情况下,Egit将在从远程分支创建分支时将上游分支作为merge参数。
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. 这意味着,如果要强制执行仅从本地分支master推送到remote/master的策略,则可以尝试在本地强制执行该策略。

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 ). 检查Egit是否尊重git config push.default current ,仅将当前分支推送到具有相同名称的上游分支(实际上可能成为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 ') (我不认为你可以在“中央”仓库强制执行它,你可以在其中添加一个服务器端钩子,update钩子:该脚本取更新分支的名称(即这里' master ',而不是下游feature1分支的名称,即这里的' feature1 ')


Note: bug 378960 has been marked as resolved (February 2014) in Egit 3.2 : 注意: 错误378960已在Egit 3.2中标记为已解决(2014年2月):

Push Branch / Initial Push wizard simplifies pushing a branch and also allows upstream configuration for new branches created by the push operation : 推送分支/初始推送向导简化了推送分支,并允许对推送操作创建的新分支进行上游配置

https://wiki.eclipse.org/images/6/6f/Egit-3.2-PushBranchWizard.png

Maybe you should advise developers to create feature-branches not from the remote-tracking branch (eg origin/master), but from the local one (master). 也许你应该建议开发人员不要从远程跟踪分支(例如origin / master)创建功能分支,而是从本地分支(master)创建功能分支。 This way, EGit will not set up any remote tracking by default. 这样,EGit默认情况下不会设置任何远程跟踪。

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. 如果您决定第一次发布分支,则应该可以在实现错误378960之后设置远程跟踪(相当于git push --set-upstream)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM