To download Git installer, access to the Git official website to open a browser, access/Git official download page (https://gitscm.com/download/win). The page automatically detects your operating system and provides an installer (usually an.exe file) suitable for Windows. Click the Download button and wait for the file to finish downloading.
Once the download is complete, double-click the downloaded.exe file to launch the installation wizard. The installation program is automatically decompressed and the installation page is displayed. Select the installation path The default installation path (such as C:\Program Files\Git) is recommended, or you can customize the path as required. Click "Next" to continue.
The installer will prompt you to select components to install. The default options already include the features most users need, such as:
Git: Terminal used to run Git commands.
Git GUI: Graphical interface tool.
Windows Explorer Integration: allows you to use Git from the right-click menu.
If certain functions are not required, deselect them. Click "Next" to continue.
Select the Start menu folder and select Git's Start menu folder name, usually using the default value. Click "Next" to continue.
This step of adjusting path options is very important because it determines the availability of Git commands on your system. Recommended option: Select "Use Git from the Windows Command Prompt" (use Git from the Windows command prompt). This allows you to use Git commands directly in cmd and PowerShell.
If you don't need to Use Git in the Windows command prompt, you can select "Use Git and optional Unix tools from the Git only" (use Git in Git only). Click "Next" to continue.
Configure the default text editor. Git needs a default text editor for things like submitting information. It is recommended to select "Use Visual Studio Code as Git's default editor", if you do not have VS Code installed, you can select "Use Notepad" or another editor. Click "Next" to continue.
Configure additional options to adjust line end conversions: Select "Checkout Windowsstyle, commit Unixstyle line endings" (check out Windowsstyle, commit Unixstyle), which is the recommended option to avoid end-of-line issues when collaborating across platforms.
Enable file system monitoring: You are advised to select Enable file system caching to improve performance. Enable Git Credential Manager: You are advised to select Enable Git Credential Manager to help you manage Git repository authentication information. Click "Next" to continue. Configure the experimental options, this step can usually be skipped unless you want to try out the latest Git features. Click "Next" to continue. After the installation is complete, click the "Install" button to begin the installation process. After the installation is complete, click the "Finish" button.
To verify the installation, open the command prompt or PowerShell, press the Win + R key, type cmd or powershell, and press Enter. Run the Git command and enter the following command to verify that Git is installed correctly:
git version
If the installation is successful, the system will return Git version information, such as:
git version 2.40.0.windows1
To get the most out of Git, some basic global configuration is recommended.
1. Configure the user name and email address
Open a command prompt or PowerShell and run the following command:
git config global user.name "Your user name"
git config global user.email "Your email address"
This information will be used to submit information to ensure they are correct.
2. View the global configuration
Enter the following command to view the global configuration:
git config global list
3. Set the default branch name
If you want to change the default branch name from master to main, you can run the following command:
git config global init.defaultBranch main
After Git is installed, Git is automatically installed, which is a terminal tool based on MinGW for running Git commands.
Search for "Git" in the Start menu and open it. In Git, you can run various Git commands, such as:
git clone < repository address >
git status
git add .
git commit m "Commit Information"
git push
If git commands cannot be run at the command prompt, the environment variables may not be configured correctly. Check whether the "Use Git from the Windows Command Prompt" option is selected during the installation. Make sure to run the installer as an administrator. Right click on the installation file and select "Run as Administrator". If you need to use SSH to connect to a Git repository, you can run the following command in Git to generate an SSH key:
sshkeygen t rsa C "Your email address"
Then add the generated public key (~/.ssh/id_rsa.pub) to your Git repository services (like GitHub, GitLab).
If you encounter end-of-line issues when collaborating across platforms, make sure the "Checkout Windowsstyle, commit Unixstyle line endings" option is selected during installation.
With the above steps, you can easily install and configure Git on Windows. Git is an indispensable tool in modern development, and knowing how to use it will greatly improve your development efficiency and collaboration. If you encounter any problems during the installation process, you can refer to the official Git documentation or community resources for more help.