简体   繁体   English

在 Intellij 终端中设置 git

[英]Setup git in Intellij terminal

I want to use git in Intellij Terminal but it does not recognize the command.我想在 Intellij Terminal 中使用 git 但它无法识别该命令。 In Command Prompt and Windows power shell the command in recognized (I added the git path in System Environment Variables).在命令提示符和 Windows power shell 中识别的命令(我在系统环境变量中添加了 git 路径)。 I am also aware that Intellij has an GUI integration with Git.我还知道 Intellij 具有与 Git 的 GUI 集成。

So, can anyone tell me how can I use the git command in the Intellij terminal.那么,谁能告诉我如何在 Intellij 终端中使用 git 命令。

Setup JetBrains(InteliJ, WebStorm, PHPStorm) IDE terminal to use GIT bash设置 JetBrains(InteliJ, WebStorm, PHPStorm) IDE 终端以使用 GIT bash

  • File文件
  • Settings设置
  • (Enter 'Terminal' in search) (在搜索中输入“终端”)
  • Change Shell path to:将外壳路径更改为:

"C:\\Program Files\\Git\\bin\\sh.exe" --login -i

or或者

"C:\Program Files\Git\bin\bash.exe"

If you have another directory for installed git change it respectively.如果您有另一个用于安装 git 的目录,请分别更改它。

In the IDEA settings make sure that your terminal path leads to "usr/bin" instead of "/bin".在 IDEA 设置中,确保您的终端路径指向“usr/bin”而不是“/bin”。

IDEA 终端设置选项卡

As a result you will see pretty rich console output:结果,您将看到非常丰富的控制台 output:

结果控制台输出

The full path is not needed anymore (windows), I just replaced cmd.exe to sh.exe and bingo was his name O不再需要完整路径(windows),我只是将 cmd.exe 替换为 sh.exe,bingo 是他的名字 O

Settings > Tools > Terminal > Shell path sh.exe设置 > 工具 > 终端 > Shell 路径sh.exe

For me, it works also but only the path of Git Bash has changed in Windows:对我来说,它也有效,但只有 Git Bash 的路径在 Windows 中发生了变化:

"C:\Users\REPLACE_THIS_BY_YOUR_USER\AppData\Local\Programs\Git\bin\sh.exe" --login -i

you don't need to reinstall anything.你不需要重新安装任何东西。 Go to:去:

-File -Settings -Search for terminal - in shell path type: "C:\\Program Files\\Git\\bin\\sh.exe" --login -i (or another directory where you installed Git) Please let me know if that worked fine for you -File -Settings -Search for terminal - 在 shell 路径中输入:“C:\\Program Files\\Git\\bin\\sh.exe”--login -i(或其他安装 Git 的目录)请告诉我是否有效对你很好

I do not have to reputation to comment yet, 我还没有声誉可以发表评论,

but following some of the comments where people say it does not work anymore in Win10: 但是在人们说它在Win10中不再起作用的一些评论之后:
Please make sure you actually take the bash.exe file inside the bin folder, not the one outside. 请确保将bash.exe文件实际放在 bin文件夹中,而不是外面。 Then you don't need the -li either. 然后,您也不需要-li

This worked for me:这对我有用:

IntelliJ: File->Settings->Version Control->Git: IntelliJ:文件->设置->版本控制->Git:

On Windows Terminal 'where.exe git.exe'在 Windows 终端上'where.exe git.exe'

"C:\Program Files\Git\cmd\git.exe" “C:\Program Files\Git\cmd\git.exe”

This worked for me:这对我有用:

IntelliJ: File->Settings->Version Control->Git: IntelliJ:文件->设置->版本控制-> Git:

On the right side, Path to Git executable:在右侧,Git 可执行文件的路径:

"C:\\Program Files\\Git\\bin\\git.exe"

(Windows) To use Git in IntelliJ terminal without switching terminal emulator to GiT Bash: (Windows)要在IntelliJ终端中使用Git而不将终端仿真器切换到GiT Bash:

  • Reinstall Git 重新安装Git
  • choose "Use Git from the Windows Command Prompt" 选择“从Windows命令提示符下使用Git”
  • choose "Use Windows' default console window" 选择“使用Windows的默认控制台窗口”
  • Restart Intellij 重新启动Intellij
  • enter "git version" in terminal to confirm 在终端输入“ git version”进行确认

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

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