This guide explains how to configure Git credentials for multiple Git hosting providers.
The deployment system uses a two-tier approach for Git server configuration:
- Well-known Providers: GitHub.com and GitLab.com have automatic URLs
- Custom Servers: All other Git servers use configurable URLs with the
GIT_{NAME}_*pattern
This design provides convenience for common providers while supporting unlimited custom Git servers.
For users with just one Git provider:
# Just GitHub (URL is automatic)
GITHUB_USERNAME="myusername"
GITHUB_PAT="ghp_xxxxxxxxxxxxxxxxxxxx"For users with multiple Git accounts:
# Personal GitHub (URL is automatic)
GITHUB_USERNAME="personal-user"
GITHUB_PAT="ghp_xxxxxxxxxxxxxxxxxxxx"
# Company GitLab (custom server)
GIT_WORK_URL="https://gitlab.company.com"
GIT_WORK_USERNAME="work-user"
GIT_WORK_PAT="glpat-xxxxxxxxxxxxxxxxxxxx"
# Azure DevOps (custom server)
GIT_AZURE_URL="https://dev.azure.com/mycompany"
GIT_AZURE_USERNAME="work-email@company.com"
GIT_AZURE_PAT="xxxxxxxxxxxxxxxxxxxxxxx"This is particularly useful for consultants or developers working with multiple organizations:
# GitLab.com (personal projects - URL is automatic)
GITLAB_USERNAME="personal-user"
GITLAB_PAT="glpat-personal-token"
# Client A's GitLab (custom server)
GIT_CLIENTA_URL="https://gitlab.clienta.com"
GIT_CLIENTA_USERNAME="consultant-user"
GIT_CLIENTA_PAT="glpat-clienta-token"
# Client B's GitLab (custom server)
GIT_CLIENTB_URL="https://git.clientb.org"
GIT_CLIENTB_USERNAME="contractor-user"
GIT_CLIENTB_PAT="glpat-clientb-token"Common in large organizations:
# External GitHub for open source (URL is automatic)
GITHUB_USERNAME="public-user"
GITHUB_PAT="ghp_public-token"
# Internal GitHub Enterprise (custom server)
GIT_INTERNAL_URL="https://github.enterprise.com"
GIT_INTERNAL_USERNAME="employee-id"
GIT_INTERNAL_PAT="ghp_internal-token"
# Legacy Git server (custom server)
GIT_LEGACY_URL="https://git.legacy-system.com"
GIT_LEGACY_USERNAME="legacy-user"
GIT_LEGACY_PAT="legacy-token"The deployment system:
- Detects well-known providers:
GITHUB_*andGITLAB_*with automatic URLs - Scans your
.envfile forGIT_{NAME}_*patterns for custom servers - Groups the URL, USERNAME, and PAT for each unique server
- Configures Git Credential Manager with server-specific credential helpers
- Enables automatic authentication for
git clone,git push, etc.
Well-known providers (automatic URLs):
GITHUB_USERNAME/GITHUB_PAT- Always uses https://github.comGITLAB_USERNAME/GITLAB_PAT- Always uses https://gitlab.com
Custom servers - The {NAME} in GIT_{NAME}_{FIELD} can be anything descriptive:
GIT_COMPANY_*- for organization-specific serversGIT_CLIENT1_*,GIT_CLIENT2_*- for multiple client environmentsGIT_STAGING_*,GIT_PROD_*- for environment-specific servers
After deployment, you can verify the configuration:
# Check configured Git servers
git config --global --list | grep credential
# Test authentication (should not prompt for password)
git clone https://github.com/yourusername/your-repo.git
git clone https://gitlab.company.com/team/project.git- Use Personal Access Tokens instead of passwords
- Set minimal permissions on PATs (usually just repository access)
- Use different PATs for different servers/purposes
- Rotate PATs regularly according to your organization's security policy
- Never commit the
.envfile to version control
- "Permission denied" - Check if PAT has correct permissions
- "Authentication failed" - Verify username matches the Git server account
- "Repository not found" - Ensure URL and repository path are correct
# Test specific server authentication
git ls-remote https://github.com/yourusername/test-repo.git
git ls-remote https://gitlab.company.com/team/project.gitIf authentication works, you should see repository information without being prompted for credentials.