git 如何在 EGit 中创建合适的新本地和远程分支组合?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10111236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:45:24  来源:igfitidea点击:

How do I create a proper new local and remote branch combination in EGit?

gitegit

提问by neelance

I would like to do the following in EGit:

我想在 EGit 中执行以下操作:

$ git checkout -b newbranch
$ git push -u origin newbranch

This gives me a new local branch, pushes it to the upstream server and creates the right tracking reference. How do I do the same in EGit?

这给了我一个新的本地分支,将它推送到上游服务器并创建正确的跟踪引用。我如何在 EGit 中做同样的事情?

回答by VonC

For the first operation, you can read the EGit manual "Creating a New Local Branch "

第一次操作可以阅读EGit手册《创建一个新的本地分支

Select Team > Switch To... > New Branch

选择团队 > 切换到... > 新分支

new branch dialog

新分支对话框

For the push, see Vogella's Egit tutorial, but also the "Push ref specification"

对于推送,请参阅Vogella 的 Egit 教程,还有“推送参考规范

push a branch

推一个分支

Note: robinsthas opened bug 378960"Allow to configure upstream in Push Branch wizard" (mentioned in "EGit - set up remote tracking correctly when creating a branch").

注意:robinst已打开错误 378960“允许在推送分支向导中配置上游”(在“ EGit - 创建分支时正确设置远程跟踪”中提到)。

The problem is that this (configuring the upstream on push) is not yet done automatically when first pushing a branch.

For now you have to right click on the branch in the Git Repositories view and choose "Configure Branch", where you can set up the upstream configuration.

问题在于,当第一次推送一个分支时,这(在推送时配置上游)还没有自动完成。

现在,您必须右键单击 Git Repositories 视图中的分支并选择“ Configure Branch”,您可以在其中设置上游配置。



Note: bug 378960has 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

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