简体   繁体   English

你如何让 Git 与 IntelliJ 一起工作?

[英]How do you make Git work with IntelliJ?

I am going to use Git version control by IntelliJ Community Edition in order to make branches of the programs I intend to develop.我将使用 IntelliJ Community Edition 的 Git 版本控制来创建我打算开发的程序的分支。 I am striving to accustom myself to its functionality and I come accross obstacles.我正在努力让自己习惯它的功能,但我遇到了障碍。

I follow the instructions of the web-page http://wiki.jetbrains.net/intellij/Using_Git_Locally and although I do what it orders, when I reach Image5 I find an empty list under Default.我按照网页http://wiki.jetbrains.net/intellij/Using_Git_Locally的说明进行操作,尽管我按照它的命令进行操作,但当我到达 Image5 时,我在 Default 下找到了一个空列表。

It is possible that it does not matter I thought, so I continued the procedure.有可能我认为没关系,所以我继续了这个过程。
However when I come to most important section of Committing Changes to Master (Revision 1) the list is also empty and the commit changes does not detect any changes to my project (see Image13 and Image 14).但是,当我来到 Comitting Changes to Master(Revision 1)的最重要部分时,列表也是空的,并且提交更改没有检测到我的项目的任何更改(请参阅 Image13 和 Image 14)。

Apart from that, I receive a message when I open the project once more indicating that the Git execution path is not correct.除此之外,当我再次打开项目时收到一条消息,表明 Git 执行路径不正确。 But how can I get knowledge of what execution path should be appropriate so as to insert it?但是我怎样才能知道什么执行路径应该是合适的以便插入呢?

Does anybody know a decent order of instructions (on a web site or by his won experience) which can guide me to how I can take advantage of Git functionality to incorporate it to my work?有没有人知道一个体面的指令顺序(在网站上或通过他的经验)可以指导我如何利用 Git 功能将其合并到我的工作中? It is crucial for me to put my work through.完成我的工作对我来说至关重要。

You need to specify the executable path of Git in the Git Settings , as mentionned in the per-requesites:您需要在Git Settings 中指定 Git 的可执行路径,如 per-requesites 中所述:

The Git integration plugin is enabled and the location of the Git executable file is correctly specified on the Git page of the Settings dialog box . Git 集成插件已启用,并且在设置对话框Git 页面上正确指定了 Git 可执行文件的位置。

As long as you see "a message indicating that the Git execution path is not correct", the rest of the instructions won't work.只要您看到“提示 Git 执行路径不正确的消息”,其余的指令将不起作用。

Path to Git executable Git 可执行文件的路径

In this text box, specify the path to the Git executable file.在此文本框中,指定 Git 可执行文件的路径。
Type the path manually or click the Browse button to open the Select Path - Git Configuration dialog box and select the location of the Git executable file in the directories tree.手动键入路径或单击“浏览”按钮打开“ Select Path - Git Configuration对话框,并在目录树中选择 Git 可执行文件的位置。

See " Where is git.exe located? " for the path of Git on Windows. Windows 上 Git 的路径请参见“ git.exe 位于何处? ”。

OR或者

    c:\path\to\PortableGit-2.6.2-64-bit\usr\bin

OR或者

    c:\path\to\PortableGit-2.x.\mingw64\bin

Update 2020, three years later:三年后的 2020 年更新:

As noted by Daniel Connelly in the comments正如丹尼尔康纳利评论中指出的那样

IntelliJ now lets people install it through the path specified in the help above (just look for the " Download Now " button on the Git menu). IntelliJ 现在允许人们通过上面帮助中指定的路径安装它(只需在 Git 菜单上查找“ Download Now ”按钮即可)。
If you download Git from the website, a version that IntelliJ does not support will be installed.如果从网站下载 Git,会安装 IntelliJ 不支持的版本。

GitHub for Windows on Windows 7 currently installs Git in a path similar to this: Windows 7 上的 GitHub for Windows 当前将Git安装在类似于以下的路径中:

C:\Users\{username}\AppData\Local\GitHub\PortableGit_93e8418133eb85e81a81e5e19c272776524496c6\bin\git.exe

The guid after PortableGit_ may well be different on your system. PortableGit_之后的 guid 在您的系统上可能会有所不同。

On unix systems, you can use the following command to determine where git is installed:在 unix 系统上,您可以使用以下命令来确定 git 的安装位置:

whereis git

If you are using MacOS and did a recent update, it is possible you have to agree to the licence terms again.如果您使用的是 MacOS 并且最近进行了更新,则您可能必须再次同意许可条款。 Try typing 'git' in a terminal, and see if you get the following message:尝试在终端中输入“git”,看看是否收到以下消息:

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

On Window machine install any version of Git.在 Window 机器上安装任何版本的 Git。 I installed我安装了

Git-2.14.1-64-bit.exe Git-2.14.1-64-bit.exe

. . Got to search program and search for git.exe.必须搜索程序并搜索 git.exe。 The file can be located under该文件可以位于

C:\\Users\\sd\\AppData\\Local\\Programs\\Git\\bin\\git.exe C:\\Users\\sd\\AppData\\Local\\Programs\\Git\\bin\\git.exe

. .

Open Intelli IDEA>Settings>Version Control>Git.打开 Intelli IDEA>设置>版本控制>Git。 On Path To Git executable add the path.在 Path To Git 可执行文件中添加路径。 Click on Test button.单击测试按钮。 It will show a message as它将显示一条消息

Git executed successfully Git 执行成功

Now click on Apply and Save.现在点击应用并保存。 This will solve the issue.这将解决问题。 . .

git.exe is common for any git based applications like GitHub, Bitbucket etc. Some times it is possible that you have already installed another git based application so git.exe will be present in the bin folder of that application. git.exe 对于任何基于 git 的应用程序(如 GitHub、Bitbucket 等)都很常见。有时您可能已经安装了另一个基于 git 的应用程序,因此 git.exe 将出现在该应用程序的 bin 文件夹中。

For example if you installed bitbucket before github in your PC, you will find git.exe in C:\\Users\\{username}\\AppData\\Local\\Atlassian\\SourceTree\\git_local\\bin instead of C:\\Users\\{username}\\AppData\\Local\\GitHub\\PortableGit.....\\bin .例如,如果您在 PC 中的 github 之前安装了 bitbucket,您将在C:\\Users\\{username}\\AppData\\Local\\Atlassian\\SourceTree\\git_local\\bin而不是C:\\Users\\{username}\\AppData\\Local\\GitHub\\PortableGit.....\\bin

For Linux users, check the value of GIT_HOME in your .env file in the home directory.对于 Linux 用户,请检查主目录中.env文件中GIT_HOME的值。

  1. Open terminal打开终端
  2. Type cd home/<username>/键入cd home/<username>/
  3. Open the .env file and check the value of GIT_HOME and select the git path appropriately Open the .env file and check the value of GIT_HOME and select the git path appropriately

PS: If you are not able to find the .env file, click on View on the formatting tool bar, select Show hidden files . PS:如果找不到.env文件,点击格式化工具栏上的View ,选择Show hidden files You should be able to find the .env file now.您现在应该能够找到.env文件。

从字面上看,只是在我按下并安装 git 后一直显示此“安装 git”消息后重新启动了 IntelliJ,它消失了,并且 git 工作

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

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