Reputation: 7101
I have a rough idea that git.cmd is only a wrapper (but added to PATH by default), but I found out that git.exe works as well and I intend to use it as a workaround to this issue (comments to it rather, regarding chcp on XP64). Would that be not recommended for any reason at all? Also, is git.cmd really needed in the first place?
Note: The chcp issue I am referring to is not caused by missing PATH entries as in 'chcp' is not recognized as an internal or external command, operable program or batch file. on a Windows PC
Upvotes: 24
Views: 23910
Reputation: 301147
There are three options when you install msysgit.
The first is that nothing is put on PATH
and you have to use Git Bash.
The second is that git.cmd
and gitk.cmd
are added to PATH
so that you can use it in cmd, Powershell, cygwin etc. without affecting other tools that you have on Windows. ( This git.cmd
is a wrapper enabled you to do this, to answer the question).
The third ( my favourite) is to add all the tools, and git.exe
, in PATH
and use this. This will affect Windows tools and you will be able to use the full set of tools that MSYS comes with.
I have always used the third option. I have never seen how it affects me ( I use Powershell and powershell cmdlets and never standard Windows commands) If you are like that and you want Mingw exes at your disposal, go for the third option and you will be good.
Upvotes: 13
Reputation: 4776
git.cmd
no longer exists in current versions of msysgit (e.g. 1.8.0). git.cmd
was a wrapper that has been replaced by a new wrapped called git.exe
. This is not to be confused with the actual git.exe
.
If you take a look at the Git directory in %ProgramFiles(x86)%
or %ProgramFiles%
, you will see the following structure:
Git
|-- bin
| |-- git.exe
|-- cmd
|-- git.exe
The wrapper has existed in msysgit for a long time in order to properly set up the environment for using git from cmd.exe. If you are using the included bash shell, it will run git.exe directly.
You can compare the old cmd version with the new executable wrapper here:
You don't really need to worry about any of this magic, just understand that you should call the wrapper from anything but the msysgit bash environment. When you add git to the path in the installer, it's the Git\cmd directory that is added. I don't recommend ever adding all the included utilities to your system path, as this can cause a lot of problems, especially if you have other msys or cygwin installations. I've never actually tried it in recent memory, but I would imagine it puts both the cmd
and bin
directories in your path, with cmd
taking precedence.
For me, there is one huge advantage to the new git.exe wrapper: it makes code that calls git more portable. Previously, if I wrote a python script that called git, I would have to either execute the command with a shell environment (subprocess.Popen()
with shell=True
) or run the cmd file explicitly. Now, I can just execute a process with 'git' as the name, regardless of the OS. This is because CreateProcess() on Windows will not execute a batch file (.cmd
is an alias for .bat
), you need to invoke cmd.exe
to execute it.
Upvotes: 34
Reputation: 9752
According to the git for windows installer you have the option of adding git.exe to your path during the setup. You should be fine using that option.
Upvotes: 5