'git' is not recognized as an internal or

2019-01-02 19:52发布

I have an installation of Git for Windows, but when I try to use the git command in Command Prompt, I get the following error:

'git' is not recognized as an internal or external command,
operable program or batch file. 

How do I fix this problem?

20条回答
怪性笑人.
2楼-- · 2019-01-02 20:05

This helps for me : I set C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd in path for environment variable.

查看更多
春风洒进眼中
3楼-- · 2019-01-02 20:06

that's because at the time of installation you have selected the default radio button to use "git" with the "git bash" only. If you would have chosen "git and command line tool" than this would not be an issue.

  • Solution#1: as you have already installed git tool, now navigate to the desired folder and then right click and use "git bash here" to run your same command and it will run properly.
  • Solution#2: try installing again the git-scm and select the proper choice.

Cheers ;)

查看更多
ら面具成の殇う
4楼-- · 2019-01-02 20:07

Start->All Programs->Git->Git Bash

Takes you directly to the Git Shell.

查看更多
回忆,回不去的记忆
5楼-- · 2019-01-02 20:07

Just wanted to add to Abizern answer. If anyone is using a non-administrator account, you can create a "local" variable instead of a "system" variable which allows access to standard/limited accounts.

When on the "Environmental Variables" window:

1) Select "New..." button within the "User variables for ..." section.

2) Set the "Variable name:" as "path" and "Variable value:" as "[your-git-path]" (usually found at C:\Program Files (x86)\Git\bin).

3) Then click OK.

查看更多
长期被迫恋爱
6楼-- · 2019-01-02 20:11

If you want to setup for temporary purpose, just execute below command.

  1. open command prompt < run --> cmd >
  2. Run below command.
    set PATH=C:\Program Files\Git\bin;%PATH%
  3. Type git, it will work.

This is valid for current window/cell only, if you will close command prompt, everything will get vanish. For permanently setting, set GIT in environment variable.

a. press Window+Pause
b. click on Advance system setting.

c. Click on Environment variable under Advance Tab.

d. Edit Path Variable.

e. Add below line in end of statement.
;c:\Program Files\Git\bin;

f. Press OK!!
g. Open new command prompt .
h. Type git and press Enter

Thanks

查看更多
只若初见
7楼-- · 2019-01-02 20:12

Windows 7 32 - bit

I am using git for my Ruby on Rails application. First time so...

I created a .bat file for loading my RoR applications with the paths manually typed using this tutorial at "http://www.youtube.com/watch?v=-eFwV8lRu1w" If you are new to Ruby on Rails you might want to check it out as I followed all steps and it works flawlessly after a few trials and errors.

(The .bat file is editable using notepad++ hence no need for the long process whenever you need to edit a path, you can follow these simple process after creating a .bat file following the tutorials on the link above "file is called row.bat".)

  1. right click on the .bat file,
  2. edit with notepad++.
  3. find path.
  4. insert path below the last path you inputted.

    )
    During the tutorials I don't remember anything said in regards to using the git command so when starting a new project I had this same problem after installing git. The main issue I had was locating the folder with the bin/git.exe (git.exe did not show up in search using start menu's "search programs and files" ) NOTE I now understood that the location might vary drastically --- see below.

To locate the bin/git.exe i followed this steps

1 left click start menu and locate ->> all programs ->> GitHub inc. 2 right click git shell and select open file location 3 click through folders in the file location for the folder "bin"

(I had 4 folders named 1. IgnoreTemplates_fdbf2020839cde135ff9dbed7d503f8e03fa3ab4 2. lfs-x86_0.5.1 3. PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad ("bin/exe, found here <<-") 4. PoshGit_869d4c5159797755bc04749db47b166136e59132 )

Copy the full link by clicking on the explorers url (mine was "C:\Users\username\AppData\Local\GitHub\PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad\bin") open .bat file in notepad++ and paste using instructions on how to add a path to your .bat file from tutorials above. Problem solved!

查看更多
登录 后发表回答