Make Git from Visual Studio Community 2022 usable in Command Prompt

Tech Knowledge
Published on October 20, 2024 Last updated on October 20, 2025
Article Image

Introduction

Since installing it separately was a hassle, I wanted to use the git that Visual Studio uses internally from the command line. So, I checked the location of git.exe using where git.

PS C:\hoge> where git
PS C:\hoge>

Nothing was displayed... Let's try running where git from the command prompt.

C:\Users\koro>where git
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd\git.exe

The path was displayed here. By adding the folder of this path to the Path environment variable, git can be used from both the command prompt and PowerShell.

git -v
git version 2.45.2.windows.1
git -v
git version 2.45.2.windows.1

Get-Command (gcm)

It's good that git is now usable, but what was the reason the path wasn't displayed in PowerShell? Using the Get-Command (gcm) cmdlet found git.

PS C:\hoge> gcm git

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     git.exe                                            2.50.1.1   C:\Program Files\Microsoft Visual Studio…

To get the full path, you can run it as follows:

(gcm git).Source
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd\git.exe

It seems better to use Get-Command (gcm) instead of where when searching for executables in PowerShell.