git 通过intelliJ添加远程git repo

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

Adding a remote git repo through intelliJ

gitintellij-ideapycharm

提问by Games Brainiac

I want to know how to add a remote git repo via intelliJ, not through the git bash. Now, from what I've seen in this tutorial, it can be done, but whenever I try to push, the dialogue never comes up. If you push to the very bottom, you can see that it can be done in probably a previous version of IntelliJ. How can you do it with version 12 or rather PyCharm 2.6?

我想知道如何通过 intelliJ 添加远程 git repo,而不是通过 git bash。现在,根据我在本教程中所看到的,它可以完成,但是每当我尝试推动时,对话永远不会出现。如果你推到最底部,你可以看到它可能可以在以前的 IntelliJ 版本中完成。你怎么能用 12 版或更确切地说 PyCharm 2.6 来做到这一点?

回答by CrazyCoder

UPDATE: this feature is available since 2016.3 version.

更新:此功能自 2016.3 版起可用。

VCS| Git| Remotes| Add(Alt+Insert).

VCS| Git| Remotes| Add( Alt+ Insert)。

git remotes

git遥控器



Original answer:

原答案:

You can choose from the existing remotes, but you can't add new remotes from the UI, there is a feature request:

您可以从现有遥控器中进行选择,但不能从 UI 添加新遥控器,有一个功能请求:

  • IDEA-87099Provide ability to add remote repositories to local git repository
  • IDEA-87099提供将远程存储库添加到本地 git 存储库的能力

The workaround, for those new to Git is to use the commandline and add a remote like so:

对于那些不熟悉 Git 的人来说,解决方法是使用命令行并添加一个遥控器,如下所示:

git remote add remoteName remoteUrl

After that, the remote will show up in the pull dialog in Intellij, but it won't show any branches until you do a fetch, like so:

之后,远程将显示在 Intellij 的拉取对话框中,但在您执行提取之前它不会显示任何分支,如下所示:

git fetch remoteName

回答by Chris

If you want a menu entry, I think for now the easiest workaround is to create an "external tool" menu entry (Preferences -> Tools -> External Tools -> Add) in IntelliJ or Pycharm. I've created one that calls '/usr/bin/git' with 'remote add origin $Prompt$' (which opens a prompt window asking for the remote git URL) and the current dir field left blank. This works great for my workflow (create local git repository, later push it to a new remote one).

如果您想要菜单项,我认为目前最简单的解决方法是在 IntelliJ 或 Pycharm 中创建一个“外部工具”菜单项(首选项 -> 工具 -> 外部工具 -> 添加)。我创建了一个调用 '/usr/bin/git' 和 'remote add origin $Prompt$'(它打开一个提示窗口询问远程 git URL)并且当前的 dir 字段留空。这对我的工作流程很有用(创建本地 git 存储库,稍后将其推送到新的远程存储库)。

回答by SaeX

This isn't possible in PyCharm (for now), but if you'd like to use a GUI tool instead of the console, I would recommend SourceTree(free to use).

这在 PyCharm 中是不可能的(目前),但是如果您想使用 GUI 工具而不是控制台,我会推荐SourceTree(免费使用)。

Once set up in SourceTree (Repository-> Add Remote), it will be visible and usable in PyCharm as well.

在 SourceTree ( Repository-> Add Remote) 中设置后,它也将在 PyCharm 中可见和可用。