简体   繁体   English

在 IntelliJ IDEA 的终端工具窗口中无法识别 git 命令

[英]git command is not recognized on Terminal tool window in IntelliJ IDEA

I am trying to use Bitbucket with IntelliJ IDEA Community Edition.我正在尝试将 Bitbucket 与 IntelliJ IDEA 社区版一起使用。

  1. I went to File >> Settings... >> Plugins and installed the Bitbucket plugin.我去文件>>设置...>>插件并安装了Bitbucket插件。 The Git Integration plugin seems enabled already. Git 集成插件似乎已经启用。

  2. I went to File >> Settings... >> Other Settings >> Bitbucket and logged in.我去文件>>设置...>>其他设置>>Bitbucket并登录。

  3. I installed Git-1.9.5-preview20141217 .我安装了Git-1.9.5-preview20141217

  4. I went to File >> Settings... >> Version Control >> Git and set Path to Git executable to C:\\Program Files (x86)\\Git\\bin\\git.exe .我转到File >> Settings... >> Version Control >> Git并将Git 可执行文件的路径设置为C:\\Program Files (x86)\\Git\\bin\\git.exe Testing will find it.测试会发现。

  5. I activated all this under VCS .我在VCS下激活了所有这些。 I saw a successful message.我看到一条成功的消息。

Then I created a repository on a team.然后我在一个团队中创建了一个存储库。 Now I must do the first commit, right?现在我必须做第一次提交,对吗?

Already have a Git repository on your computer?您的计算机上已经有一个 Git 存储库? Let's push it up to Bitbucket.让我们把它推到 Bitbucket。

cd /path/to/my/repo
git remote add origin https://user@bitbucket.org/repo/s.git
git push -u origin --all # pushes up the repo and its refs for the first time
git push -u origin --tags # pushes up any tags

I opened View >> Tool Windows >> Terminal .我打开了View >> Tool Windows >> Terminal

"git" is not recognized as an internal or external command “git”不被识别为内部或外部命令

The terminal tool window is just a terminal emulator for a command shell.终端工具窗口只是一个命令 shell 的终端模拟器。 In case of Windows that shell defaults to cmd, which is completely independent of the IDE settings.在 Windows 的情况下,shell 默认为 cmd,这完全独立于 IDE 设置。 So in order for that to work you must have git in PATH environment variable.所以为了让它工作,你必须在PATH环境变量中有 git 。

You can do it this way:你可以这样做:

  1. Go to Control panel/System/Advanced System Settings进入控制面板/系统/高级系统设置
  2. Click Environment variables单击环境变量
  3. Select PATH and click Edit选择PATH并点击编辑
  4. Append following string at the end of the variable value: ;C:\\Program Files (x86)\\Git\\bin在变量值的末尾附加以下字符串: ;C:\\Program Files (x86)\\Git\\bin
    • The semicolon is important, because individual PATH entries are delimited by it分号很重要,因为单个 PATH 条目由它分隔
    • The path to git bin directory might be different on your system您的系统上 git bin 目录的路径可能不同

This works on Windows 8.1.这适用于 Windows 8.1。 It might be a little different on older versions of Window.在旧版本的 Window 上可能会有所不同。 Just in case here is a link which covers this procedure on more Windows versions.以防万一这里有一个链接,它涵盖了更多 Windows 版本的此过程。

Or you could set Git Bash as the shell for the Terminal tool window.或者您可以将 Git Bash 设置为终端工具窗口的外壳。 Personally I prefer this approach on Windows computers.我个人更喜欢在 Windows 计算机上使用这种方法。 You can do it by going into Settings/Terminal and setting Shell path to something like "C:\\Program Files (x86)\\Git\\bin\\sh.exe" --login -i (this might be different on your computer).您可以通过进入Settings/Terminal并将Shell 路径设置为"C:\\Program Files (x86)\\Git\\bin\\sh.exe" --login -i (这可能在您的计算机上有所不同)来实现。

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

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