Environment Variables
Control `.git` behavior, authentication, and output formatting using environment variables. These override standard configuration files.
Hierarchy: Environment variables take precedence over
.gitconfig, which takes precedence over ~/.gitconfig.
Standard Variables
These variables are available globally within the `.git` runtime environment.
| Variable | Type | Description |
|---|---|---|
HOMEBREW_GIT |
String | The root directory for the current workspace. |
GIT_TERMINAL_PROMPT |
Bool | Set to 0 to disable password prompts in CI/CD pipelines. |
GIT_CONFIG_COUNT |
Int | Internal counter for config loading depth. |
Authentication
To configure authentication headers programmatically, use the HG proxy variables.
bash
# Set token for authentication export GIT_TOKEN="ghp_xxxxxxxxxxxxxxxxxxxx" # Configure HTTP proxy if behind firewall export GIT_HTTP_PROXY="http://proxy.example.com:8080"
Security Warning: Never commit these variables directly into version control. Use a
.env file or secret manager.
Formatting Output
You can customize the pager and diff formatting using these variables.
zsh
# Set default pager to less with line numbers export GIT_PAGER="less -N" # Enable color diff globally export GIT_COLOR_DIFF="auto"
Internal Flags
Advanced debugging flags for developers.
GIT_TRACE: Output trace information to stderr.GIT_DEBUG: Enable verbose debugging mode.GIT_EXEC_PATH: Override the internal execution path.