6

I want to run Git commands directly on windows CMD, I downloaded Git from here http://msysgit.github.io/ but it has its own terminal called "Git Bash.vbs" and it consider the installation directory as the root. Any answers even 'No you can't run it on CMD terminal' would be apprciated.

Cheers.

sazz
  • 3,193
  • 3
  • 23
  • 33
  • There's nothing magic about git that would prevent it from running in a Windows command terminal. I don't know anything about the specific git version you're using, but I would suggest that if it's giving you trouble, you should seek out another. I've not tried it, but http://git-scm.com/download/win may be helpful. – mah Apr 16 '14 at 14:59
  • 1
    Probably duplicate of [Command-line Git on Windows](http://stackoverflow.com/questions/11000869/command-line-git-on-windows) – Bauhaus Apr 16 '14 at 15:00
  • the version that you mentioned is a prior version of what I already downloaded, but that's not the problem. After the installation you can't run Git on CMD, you should run it from its own installed command line, and I want to run it from CMD like on MAC terminal. – sazz Apr 16 '14 at 15:06

2 Answers2

8

The Git for Windows installer actually has a setting to set the PATH accordingly, so you can run Git from within the Windows command lines (cmd.exe, and also PowerShell, but anywhere else too). You just need to select the option when installing:

Run Git from the Windows Command Prompt

As the installer says, if you select “Run Git from the Windows Command Prompt”, it will add (only) Git to the PATH, and you can simply execute it from other places. The default, “Use Git Bash only”, will not set the PATH but requires you to run the bundled Git Bash to use Git.

poke
  • 369,085
  • 72
  • 557
  • 602
2

Assuming Windows 7 is your OS: Go to Control Panel->System->Advanced System Options->Advanced->Environment_Variables(button near bottom). You should see at least three variables there: PATH, TEMP, TMP Click on PATH, click edit.

Scroll to the end of whatever PATH variables are already set. Don't modify them. Add a semi-colon (";") to the end, and then type/copy-paste/whatever the exact path to the 'bin' subdirectory of where you installed git. For example: "C:\Program Files (x86)\Git\bin\"

Apply the changes, and CMD should now run git commands.

By the way, this procedure is what you should do to also get other commands to run directly in CMD terminal as well.

  • **2022 UPDATE** The default installation directory is now %USERPROFILE%\AppData\Local\Programs\Git. – cb4 Aug 02 '22 at 15:09