119

I want to use git in Intellij Terminal but it does not recognize the command. In Command Prompt and Windows power shell the command in recognized (I added the git path in System Environment Variables). I am also aware that Intellij has an GUI integration with Git.

So, can anyone tell me how can I use the git command in the Intellij terminal.

Seagull
  • 13,484
  • 2
  • 33
  • 45
user2302448
  • 1,195
  • 2
  • 9
  • 6
  • I'm not windows user, but I think, you could get some usefull info from [this post](https://codeaweso.me/2013/12/cygwin-terminal-with-intellij-idea-13/) You can try setup path to bashshell, or install cygwin, and setup git there. Also [this](http://stackoverflow.com/a/15201881/1601606) may be helpfull. – Seagull Feb 10 '14 at 17:51

7 Answers7

307

Setup JetBrains(InteliJ, WebStorm, PHPStorm) IDE terminal to use 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.

Bazer Con
  • 105
  • 4
Aleksej Shovgenja
  • 3,502
  • 1
  • 14
  • 12
  • 2
    Is there a way to specify Mintty somehow? Doing it this way does not allow me to do a few things, like be able to print the unicode char `\u03BB` – DanGordon Jan 18 '16 at 21:23
  • I'm not shure, but i think JetBrains plugin "Command Line Tool Support" will be usefull for purposes like that. – Aleksej Shovgenja May 05 '16 at 11:53
  • 2
    Dont forget the to put Quotes for directory. Intellij had issues launching terminal – Srujan Kumar Gulla May 19 '16 at 15:37
  • 3
    Or to `C:\Program Files\Git\bin\bash.exe` – spencer.sm Apr 22 '18 at 07:03
  • 3
    This does no longer work with Win10 and PHPStorm 2018.2.6 The bash window just pops up outside the IDE and closes imediately again. – macbert Mar 21 '19 at 11:07
  • Following the thread here helped me to fix it: https://intellij-support.jetbrains.com/hc/en-us/community/posts/207627665-Can-t-start-the-git-bash-in-the-terminal-Tools-Terminal- I guess changing form to float, windowed and back to docked fixed it – macbert Mar 21 '19 at 11:29
  • On Windows 10 I was running into an odd error at first when specifying "C:\Program Files\Git\bin\sh.exe" --login -i, the error went away after I created a .bashrc file. Once I created the file (no content in the file) the terminal opened and gave a message that it created a .bash_profile file. I saved the file to this location C:\Users\userName\.bashrc – edjm Jun 04 '19 at 15:45
  • Don't forget to **restart** Intellij – S_intg Jul 26 '19 at 14:44
  • This anwer can't be correct - "C:\Program Files\Git\bin\sh.exe" --login -i" is by no means a path. And yes, it does not work with PyCharm 2019.3 / Windows 10 / git-scm 2.25 – wh81752 Jan 23 '20 at 16:16
  • 25
    If you're using Git For Windows, make sure **not** to use _C:\Program Files\Git\git-bash.exe_, but _C:\Program Files\Git\bin\bash.exe_ - otherwise the command prompt will open in a separate window! – user2428118 Feb 06 '20 at 09:20
  • Open a new terminal after to make sure the changes are applied. 'Crtl + Shift - T' for IntelliJ Idea – CodeMonkey123 Apr 09 '20 at 11:01
  • 2
    If you get broken-looking output (`[0;39;1m`) from Gradle, [setting `TERM=cygwin`](https://github.com/gradle/gradle/issues/13279#issuecomment-772957621) should solve that for now. – Brad Turek Mar 26 '21 at 08:20
6

For me, it works also but only the path of Git Bash has changed in Windows :

"C:\Users\REPLACE_THIS_BY_YOUR_USER\AppData\Local\Programs\Git\bin\sh.exe" --login -i
jpmottin
  • 2,717
  • 28
  • 25
  • Worked fine for my setup: Windows 10, IntelliJ IDEA 2022.2 (Ultimate Edition), both paths `"C:\Users\my-user-name\AppData\Local\Programs\Git\bin\sh.exe" --login -i` and `"C:\Users\my-user-name\AppData\Local\Programs\Git\bin\sh.exe" --login -i` worked. – belgoros Aug 09 '22 at 07:23
4

In the IDEA settings make sure that your terminal path leads to "usr/bin" instead of "/bin".

IDEA terminal settings tab

As a result you will see pretty rich console output:

Result console output

Orachigami
  • 416
  • 3
  • 4
2

The full path is not needed anymore (windows), I just replaced cmd.exe to sh.exe and bingo was his name O

Settings > Tools > Terminal > Shell path > sh.exe

Bazer Con
  • 105
  • 4
Alvic
  • 49
  • 2
1

In my case, the Git Bash through IntelliJ had TERM=xterm-256color. Regular Git Bash had TERM=xterm

To fix the garbled characters issue in IntelliJ Idea, Go to "File | Settings | Tools | Terminal"

Environment Variables:  TERM=cygwin

In IntelliJ Terminal, Shell Path I was using was already:

C:\Users\<userId>\programs\Git\bin\bash.exe --login -i

John
  • 316
  • 4
  • 6
0

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)
Bazer Con
  • 105
  • 4
-2

This worked for me:

IntelliJ: File->Settings->Version Control->Git:

On the right side, Path to Git executable:

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

Siamak
  • 15
  • 2