git 如何使用 smartgit 创建远程分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3493326/
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-10 08:54:23  来源:igfitidea点击:

How to create a REMOTE branch using smartgit?

gitsmartgit

提问by Somedeveloper

How to create a REMOTE branch using smartgit?

如何使用 smartgit 创建远程分支?

采纳答案by ewall

With the usual command-line Git, a remote reference is automagically created when you clone a remote repository with git clone href://...(which would call the remote 'origin' by default).

使用通常的命令行 Git,当您使用git clone href://...(默认情况下会调用远程“来源”)克隆远程存储库时,会自动创建远程引用。

Or, you can add it manually with a command like git remote add origin href://.... To push up a branch, you would execute git push origin branchname. (See more detailed examples and explanation here.)

或者,您可以使用类似的命令手动添加它git remote add origin href://...。要上推一个分支,您将执行git push origin branchname. (在此处查看更详细的示例和解释。)

However, I can see that SmartGit is a little different (I have not used it myself), and is GUI-based. As far as I can see, the 'Clone' and 'Push' commands mentioned above can be found in SmartGit's 'Remote' menu. If you want to add a reference to a remote repository, is there an 'Add' option in the 'Remote' menu??

但是,我可以看到 SmartGit 有点不同(我自己没有使用过),并且是基于 GUI 的。据我所知,上面提到的“克隆”和“推送”命令可以在 SmartGit 的“远程”菜单中找到。如果要添加对远程存储库的引用,“远程”菜单中是否有“添加”选项?

回答by Jarrod Smith

The Push Advanced trick didn't work for me. The only way I can seem to do this on SmartGit 3.0.6 was:

Push Advanced 技巧对我不起作用。我似乎可以在 SmartGit 3.0.6 上做到这一点的唯一方法是:

  • Remote -> Manage Remotes, then click Addand put in the details of the remote e.g. 'master', 'https://github.com/SomeCompany/SomeRepo'.
  • Then click Pull. It will say that it can only update submodules blah blah, hit OK. The Fetch will output a warning "no common commits".
  • Now go to Branch -> Branch Manager. Right-click on your local branch and choose Set Tracked Branch...then choose the appropriate remote branch.
  • Fetch again. Properly this time.
  • Finally do your push to the remote.
  • 远程 -> 管理远程,然后单击添加并输入远程的详细信息,例如“master”、“ https://github.com/SomeCompany/SomeRepo”。
  • 然后点击。它会说它只能更新子模块等等,点击确定。Fetch 将输出警告“没有常见的提交”。
  • 现在去Branch -> Branch Manager。右键单击您的本地分支并选择Set Tracked Branch...然后选择适当的远程分支。
  • 再取。这次恰到好处。
  • 最后推送到遥控器。

It's quite an achievement for a GUI tool to make something lessintuitive, but SmartGit does an amazing job of it here.

GUI 工具使某些东西变得不那么直观是一项相当大的成就,但 SmartGit 在这里做得非常出色。

Order of events

事件顺序

回答by c31983

SmartGit does not make this very clear, but there is an easy way to accomplish this. First off, I'm assuming you know about branch tracking. A local branch will in general track a remote branch (probably on a server). This allows you to push and pull changes to and from that branch.

SmartGit 并没有把这一点说得很清楚,但是有一种简单的方法可以做到这一点。首先,我假设您了解分支跟踪。本地分支通常会跟踪远程分支(可能在服务器上)。这允许您从该分支推送和拉取更改。

The trick is to reset the tracking branch so it is not tracking anything. To do this, go to Branch ? Branch Manager, right click on your local branch, then click 'Reset Tracked Branch...'

诀窍是重置跟踪分支,使其不跟踪任何内容。为此,请转到 Branch ? 分支经理,右键单击您的本地分支,然后单击“重置跟踪分支...”

Now when you are ready to push your changes as a new remote branch, go to Remote ? Push Advanced and make sure that the 'Push current branch' radio is the onlything selected.

现在,当您准备好将更改作为新的远程分支推送时,请转到 Remote ? 推送高级并确保“推送当前分支”无线电是唯一选择的内容。

When you press the push button, it is going to ask you if you want to configure tracking. Press the skip button. You should now have a remote branch.

当您按下按钮时,它会询问您是否要配置跟踪。按跳过按钮。您现在应该有一个远程分支。

Note: Name your local branch what you want it to be named as a remote branch beforeyou push it.

注意:推送之前将本地分支命名为远程分支。

回答by ajaybc

In SmartGit 4.5.2, it is really easy. Just go to Remote > Addand just type the URL of the remote

在 SmartGit 4.5.2 中,这真的很容易。只需转到Remote > Add并输入遥控器的 URL

回答by Frank Nocke

As of SmartGit 6.5.9 ( August 2015 ):

从 SmartGit 6.5.9(2015 年 8 月)开始:

  • check out (double click) the branch, that your new one should be based on (most likely you already did that)
  • right-click (as described) in the Branches-Tab on the local branch, you want your new branch based on. Use the (o) Custom Ref. The field is disturbingly short, wrongly making me think, this might only be for short git hashes like 92fa03dor such, but indeed setting new branch names like feature/JIRA-1234-your-feature-heredo work as expected:

    enter image description here

  • double-click the new remote branch in the Branches Tab (origin fold-open). SmartGit will as usual offer to create a properly named and tracked local branch

  • 检查(双击)分支,您的新分支应基于该分支(很可能您已经这样做了)
  • 在本地分支上的 Branches-Tab 中右键单击(如所述),您希望新分支基于。使用 (o) 自定义参考。该字段短得令人不安,让我错误地认为,这可能仅适用于诸如此类的短 git 哈希92fa03d,但确实设置了新的分支名称,如feature/JIRA-1234-your-feature-here按预期工作:

    在此处输入图片说明

  • 双击分支选项卡中的新远程分支(原点折叠打开)。SmartGit 将像往常一样提供创建一个正确命名和跟踪的本地分支

回答by user3546411

The current SmartGit version (6.5.8) does this easily with a Push Tocommand.

当前的 SmartGit 版本 (6.5.8) 可以通过Push To命令轻松完成此操作。

  • Push Tois in a context menu in the Branchestab(not in a window level Branchmenu).
  • The context menu is opened by right mouse clicking on the branch you want to push.
  • Just enter the name of the remote branch you want to create in the Push Todialog.
  • Push To位于Branches选项卡的上下文菜单中(不在窗口级Branch菜单中)。
  • 右键单击要推送的分支可打开上下文菜单。
  • 只需在Push To对话框中输入要创建的远程分支的名称。

SmartGit will create the remote branch, push current branch HEAD to it, and set the remote branch as your tracking branch.

SmartGit 将创建远程分支,将当前分支 HEAD 推送到它,并将远程分支设置为您的跟踪分支。

(All of this is assuming you want to create the branch in your standard origin tracking repo for the current local repo.)

(所有这些都假设您想在当前本地存储库的标准源跟踪存储库中创建分支。)

回答by Benjol

I don't know that you can createa remote branch, but I think you might find what you're looking for under Project/Clone...

我不知道你可以创建一个远程分支,但我想你可能会在下面找到你要找的东西Project/Clone...

(Disclaimer, I've only used this once, and it was a while ago)

(免责声明,我只使用过一次,而且是前一段时间)

You could try asking on their forum/discussion list. They are very good at answering mail sent to support to (Help/Contact Support...)

您可以尝试在他们的论坛/讨论列表中提问。他们非常擅长回复发送给支持人员的邮件 ( Help/Contact Support...)