How to Install Git on Windows Using Command Prompt (CMD)

Git is an essential tool for modern developers, enabling version control and collaboration in software projects. While Git can be installed through graphical interfaces, using the Command Prompt (CMD) gives you greater control and is preferred by many developers for scripting or automation.

In this guide, we’ll walk you through the step-by-step process of installing Git on a Windows machine using the command line.


✅ Step 1: Check if Git Is Already Installed

Before installing, it’s good to check whether Git is already on your system.

Open CMD and run:

git --version

If Git is installed, you’ll see something like:

git version 2.44.0.windows.1

If not, you’ll see an error like:

'git' is not recognized as an internal or external command

🔽 Step 2: Download the Git Installer via Command Line

To install Git via CMD, we’ll use PowerShell with winget (Windows Package Manager), which is available on Windows 10 (2004+) and Windows 11.

Open CMD as Administrator, then run:

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

This command will:

  • Automatically download the latest Git for Windows.
  • Launch the installer with default settings.

📝 If winget is not available, update your App Installer from the Microsoft Store.


💡 Step 3: Verify the Installation

Once installation is complete, verify Git was successfully installed:

git --version

You should now see the installed version of Git printed in the terminal.


🔧 Step 4: Configure Git (First-Time Setup)

Set your name and email, which are used in your Git commits:

git config --global user.name "Your Name"
git config --global user.email "yo*@ex*****.com"

Optional: Set your default text editor for Git (e.g., Notepad++):

git config --global core.editor "notepad"

🛠 Troubleshooting Tips

  • Command not found: Ensure Git was added to your system PATH. You can verify this by restarting CMD or checking environment variables.
  • Permission denied: Run CMD as administrator if you hit access issues during installation.

📦 Alternative: Install Git Using Chocolatey

If you use Chocolatey, another Windows package manager, run:

choco install git

Make sure Chocolatey is already installed on your system.


✅ Summary

TaskCommand
Check if Git is installedgit --version
Install Git using wingetwinget install --id Git.Git -e --source winget
Configure Git username/emailgit config --global user.name "Your Name"
Set Git emailgit config --global user.email "yo*@ex*****.com"

🏁 Conclusion

Installing Git via Command Prompt is quick, efficient, and ideal for developers who prefer automation and scripting. Once installed, you’re ready to clone repositories, manage version control, and collaborate with your team—all from the terminal.

Sharing Is Caring:

Leave a Comment