Git Setup and Initialization on Windows
To set up Git on a Windows machine, follow these steps:
Step 1: Install Git
Download Git:
Go to the Git for Windows website.
Download the installer for Windows.
Install Git:
Run the downloaded installer.
Follow the installation steps:
Choose the default editor (e.g., Nano or VS Code).
Adjust your PATH environment:
Select "Git from the command line and also from 3rd-party software."
Configure line-ending conversions:
Choose "Checkout Windows-style, commit Unix-style line endings."
Finish the setup with the recommended defaults.
Verify Git Installation: Open a terminal (Command Prompt or Git Bash) and run:
1git --version
Step 2: Configure Git
Once installed, configure Git with your user information.
Set Your Name:
xxxxxxxxxx11git config --global user.name "Your Name"Set Your Email:
xxxxxxxxxx11git config --global user.email "your.email@example.com"Check Configuration:
xxxxxxxxxx11git config --list
Step 3: Generate SSH Key (Optional for Remote Repositories)
To authenticate with services like GitHub, Azure DevOps, or GitLab using SSH:
Generate SSH Key:
xxxxxxxxxx11ssh-keygen -t rsa -b 4096 -C "your.email@example.com"Press
Enterto save the key in the default location.Enter a passphrase (optional).
Add SSH Key to Agent:
xxxxxxxxxx11ssh-add ~/.ssh/id_rsaCopy SSH Key:
xxxxxxxxxx11clip < ~/.ssh/id_rsa.pubThis copies the public key to the clipboard.
Add the SSH Key to Your Remote Repository (e.g., GitHub/Azure DevOps):
Go to the settings of your remote repository.
Add the SSH key under the SSH Keys section.
Step 4: Initialize a Git Repository
Create a New Project Directory:
xxxxxxxxxx21mkdir MyProject2cd MyProjectInitialize Git:
xxxxxxxxxx11git initThis creates a
.gitdirectory in your project folder to track changes.
Step 5: Optional Git Settings for Windows
Set Default Branch Name: e.g.,
maininstead ofmasterxxxxxxxxxx11git config --global init.defaultBranch mainSet Credential Manager: Windows supports Git Credential Manager, which stores credentials securely.
xxxxxxxxxx11git config --global credential.helper manager
Step 6: Visual Studio Code Integration
Install VS Code:
Download from Visual Studio Code.
Install Git Extension:
Open the Extensions view (
Ctrl+Shift+X) and install the Git extension.
Use Git in VS Code:
Open your project folder in VS Code.
Use the Source Control tab to stage, commit, and push changes.
Verification
Run
git statusin the terminal to check the status of your repository.Make a simple change, add a file, and commit it:
xxxxxxxxxx31echo "Hello, Git!" > README.md2git add README.md3git commit -m "Initial commit"This completes the Git setup and initialization process on Windows. Have Fun!






















Leave a Reply