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
It is up to you to decide which you want to use. As many others, I recommend you to learn Git with command line before switching to a graphical interface. If you don't know which to choose between Git Bash and Git CMD, I'd go for Git Bash since bash is a really useful tool to learn.
At its core, Git is a set of command line utility programs that are designed to execute on a Unix style command-line environment. Modern operating systems like Linux and macOS both include built-in Unix command line terminals. This makes Linux and macOS complementary operating systems when working with Git.
Using Git. Now it's installed, Git will work the same way as it does on Linux or OS X. All you have to do is load Command Prompt (Load the Start menu, then click "Run", type cmd and hit enter), then you can use Git commands as normal.
The default path on windows is C:\Program Files (x86)\Git . The name of the executable is not git.exe on all systems.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With