A Git credential helper that resolves credentials by organization namespace, solving the multi-org authentication problem on shared Git hosting platforms (GitLab, GitHub).
When working across multiple organizations on the same platform (e.g., gitlab.com/org1 and gitlab.com/org2), standard credential helpers can't reliably distinguish which credentials to use. This tool derives a namespace from the URL path (host/first-path-segment) and stores credentials per namespace.
- Namespace-based resolution:
gitlab.com/org1andgitlab.com/org2use separate credential sets automatically - Store-once-don't-ask: Credentials are prompted once, stored, and reused. Erased only when git reports auth failure.
- Pluggable backends: macOS Keychain and 1Password (via
opCLI) - Platform-aware: Knows GitLab uses
oauth2username with PATs, GitHub usesx-access-token, etc. - Zero-config for simple setups: Works with sensible defaults out of the box
brew install imcitius/tap/git-credentials-orggo install github.com/imcitius/git-credentials-org/cmd/git-credentials-org@latestOr clone and build:
git clone https://github.com/imcitius/git-credentials-org.git
cd git-credentials-org
go build -o git-credentials-org ./cmd/git-credentials-org
sudo mv git-credentials-org /usr/local/bin/After installing, run:
git-credentials-org installThis will:
- Create a default config at
~/.config/git-credentials-org/config.toml - Set
credential.helperandcredential.useHttpPathin your global.gitconfig
Add to your ~/.gitconfig (the empty helper = line clears any previously configured helpers):
[credential]
helper =
helper = /usr/local/bin/git-credentials-org
useHttpPath = trueConfig file location: ~/.config/git-credentials-org/config.toml
[defaults]
backend = "keychain" # "keychain" or "onepassword"
log_level = "warn"
# Per-host settings
[hosts."gitlab.com"]
provider = "gitlab" # Enables GitLab-specific behavior (oauth2 username)
# backend = "onepassword" # Override backend for this host
[hosts."github.com"]
provider = "github"
# Backend-specific settings
[backends.onepassword]
vault = "Development" # 1Password vault name
# account = "my.1password.com"| Variable | Description |
|---|---|
GIT_CREDENTIALS_ORG_CONFIG |
Custom config file path |
GIT_CREDENTIALS_ORG_DEBUG |
Set to 1 for debug logging |
- Git calls
git-credentials-org getwithprotocol,host, andpathon stdin - The helper derives a namespace:
gitlab.com+org1/project/repo.git→gitlab.com/org1 - Looks up credentials in the configured backend for that namespace
- If found, returns them. If not, prompts the user once and stores them.
- On
store(successful auth): updates the backend with working credentials - On
erase(failed auth): removes credentials so the nextgetwill prompt again
Uses the macOS Keychain via the system security framework. Credentials are stored as JSON under the service name git-credentials-org with the namespace as the account key.
No additional setup required.
Requires the 1Password CLI (op) to be installed.
Credentials are stored as Login items in the specified vault with title pattern git-credentials-org: <namespace>.
Supports:
- Interactive use (biometric unlock via
op) - Service accounts (
OP_SERVICE_ACCOUNT_TOKENenvironment variable)
# Enable verbose logging
GIT_CREDENTIALS_ORG_DEBUG=1 git pull
# Or use the flag
git-credentials-org --verbose get <<EOF
protocol=https
host=gitlab.com
path=myorg/myproject.git
EOFMIT