Before configuring your Windows Server as a Git host, ensure you have:
- Administrative access to the Windows Server (2012 R2 or newer recommended)
- Git for Windows installed (latest version of
msysgit
or Git for Windows) - Proper network/firewall configuration for remote access (SSH or HTTPS)
- Basic familiarity with command-line Git operations
For a centralized repository structure similar to SVN trunk, create bare repositories for each project:
# SSH into your Windows server or use RDP
mkdir C:\GitRepos
cd C:\GitRepos
# Create main repository container
git init --bare AllProjects.git
# Create individual project repositories
git init --bare ProjectA.git
git init --bare ProjectB.git
Set proper NTFS permissions for your repository directory:
- Right-click
C:\GitRepos
→ Properties → Security - Add your developer group/users with Modify permissions
- Ensure SYSTEM and Administrators have Full Control
Developers can clone these repositories using either SSH or file protocol:
# Using SSH (requires SSH server setup)
git clone ssh://username@serverIP/C:/GitRepos/ProjectA.git
# Using file protocol (for local network)
git clone file:////serverIP/GitRepos/ProjectA.git
For those preferring GUI tools:
- GitExtensions: Provides repository management through Windows Explorer context menu
- TortoiseGit: Integrates with Windows Shell for easy repository creation
- GitHub Desktop: Can connect to local repositories
Create a PowerShell script for batch repository setup:
# CreateGitRepos.ps1
param (
[string]$repoPath = "C:\GitRepos",
[string[]]$projectNames = @("WebApp", "MobileApp", "API")
)
foreach ($project in $projectNames) {
$fullPath = Join-Path -Path $repoPath -ChildPath "$project.git"
git init --bare $fullPath
Write-Host "Created repository at $fullPath"
}
For internet-accessible repositories:
- Configure Windows Firewall to allow Git port (default 9418 for Git protocol)
- Consider using Git over SSH (port 22) for encrypted communication
- Implement certificate-based authentication for additional security
- Regularly run
git gc
on repositories to optimize storage - Set up automated backups of the GitRepos directory
- Monitor repository growth using
git count-objects -v
When setting up Git on a Windows server for team collaboration, you typically need two components:
- A central repository server (analogous to SVN's trunk)
- Multiple project repositories under this central structure
While MSYSGit works for local operations, for server setup I recommend:
- Git for Windows (modern replacement for MSYSGit)
- Bonobo Git Server (lightweight IIS-based Git server with GUI)
1. Install Git for Windows on your server:
choco install git -y
2. Install Bonobo via Web Platform Installer or manually:
Install-Package Bonobo-Git-Server
Create your root directory structure:
mkdir C:\GitRepos
cd C:\GitRepos
mkdir ProjectA.git
mkdir ProjectB.git
cd ProjectA.git
git init --bare
Configure proper NTFS permissions for your team:
icacls "C:\GitRepos" /grant "DOMAIN\Developers:(OI)(CI)(M)"
Team members can clone using:
git clone http://yourserver/Bonobo.Git.Server/ProjectA.git
For developers using Visual Studio:
- Add the remote in Team Explorer
- Use the built-in Git tools for commits
- Push to your central server
Create a PowerShell script for new projects:
param($projectName)
$repoPath = "C:\GitRepos\$projectName.git"
mkdir $repoPath
cd $repoPath
git init --bare
Write-Host "Created new repository at $repoPath"