Link GitHub with Windows Server 2022 failed

The IT Guys 85 Reputation points
2026-10-27T18:04:50.97+00:00

git is not recognized as an internal or external command. I tried several attempts but no way forward, Kindly help

Windows for business | Windows 365 Enterprise
0 comments No comments

Answer accepted by question author
Ronald Sabiiti 1,830 Reputation points Independent Advisor
2026-10-27T18:54:41.6966667+00:00

Hello The IT Guys,

The error usually means Git is either not installed on your Windows Server 2022 machine or its installation path is missing from the system PATH.

Please try the following:

Download and install Git for Windows.

Close and reopen Command Prompt or PowerShell.

Run git --version to confirm that Git is available.

If Git is already installed, check that C:\Program Files\Git\cmd is included in your system PATH.

Reference: GitHub guide to installing Git.

If the issue persists, please let me know whether Git is already installed and which terminal you're using, so we can guide you through the next steps.

If this information was helpful, please click Accept Answer.

Thank you for choosing Microsoft Q&A.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Vasileios Dionysopoulos 821 Reputation points
    2026-10-27T18:37:00.3666667+00:00

    Hi there!

    I ran a quick lab on Windows Server 2025 and reproduced the same "git is not recognized" error. Installing Git resolved the issue, and I successfully cloned a GitHub repository afterward.

    For Windows Server 2022, here's what I'd suggest:

    Download and install Git for Windows from https://git-scm.com/install/windows.

    Close PowerShell and open a fresh session.

    Run git --version to confirm Git is recognized.

    If you still get the same error, try:

    & "C:\Program Files\Git\cmd\git.exe" --version

    If this works, Git is installed but its PATH entry needs fixing. Check that C:\Program Files\Git\cmd is included in your PATH.

    I've attached screenshot from my lab showing the successful installation and GitHub clone.

    User's image

    Give it a try and let us know how it goes!

    Hope this helps!

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-10-27T18:06:02.6333333+00:00

    Install Git for Windows or repair its PATH entry, then open a new PowerShell session and verify that git.exe is discoverable.

    1. Determine whether Git is installed

    Run:

    $git = 'C:\Program Files\Git\cmd\git.exe'
    
    if (Test-Path $git) {
        & $git --version
    } else {
        Write-Host 'Git for Windows is not installed in the standard location.'
    }
    
    • If a Git version appears, continue to Step 2.
    • If the file is missing, install Git for Windows. Git is not included with Windows by default; after installation it should be usable from PowerShell.^1^

    You can install it from PowerShell with:

    winget install --id Git.Git -e --source winget
    

    This WinGet command is documented by Microsoft.^2^

    Alternatively, download the official Git for Windows installer and accept its default settings.^3^

    After installation, close every PowerShell window and open a new one, then run:

    git --version
    

    2. Repair PATH if Git is installed

    If the full-path command worked but git --version still does not, add Git’s command directory to the machine-level PATH.

    Open PowerShell as Administrator, then run:

    $gitPath = 'C:\Program Files\Git\cmd'
    $machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
    
    if (($machinePath -split ';') -notcontains $gitPath) {
        [Environment]::SetEnvironmentVariable(
            'Path',
            "$machinePath;$gitPath",
            'Machine'
        )
    }
    

    Close PowerShell, open a new session, and verify:

    Get-Command git
    git --version
    

    Get-Command discovers applications available through the current session’s PATH.^4^

    3. Configure Git and connect to GitHub

    Once git --version succeeds, configure the identity attached to your commits:

    git config --global user.name "Your Name"
    git config --global user.email "[Email]"
    

    Then clone an existing GitHub repository:

    cd C:\Projects
    git clone https://github.com/OWNER/REPOSITORY.git
    

    Git for Windows includes Git Credential Manager, so the first authenticated GitHub operation can prompt you to sign in. GitHub requires Git to be installed locally before it can be used from the command line.^5^


    References

    1. Install and set up Git - Azure DevOps | Microsoft Learn
    2. Get started with Git from the command line
    3. Git - Install for Windows
    4. Get-Command-Syntax
    5. Set up Git - GitHub Docs
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.