Skip to content

hickford/git-credential-azure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-credential-azure

git-credential-azure is a Git credential helper that authenticates to Azure Repos (dev.azure.com). Azure Repos is part of Azure DevOps.

The first time you authenticate, the helper opens a browser window to Microsoft login. Subsequent authentication is non interactive.

Installation

All platforms

Download binary from https://github.com/hickford/git-credential-azure/releases.

Then test that Git can find the application:

git credential-azure

If you have problems, make sure that the binary is located in the path and is executable.

Linux

Several Linux distributions include a git-credential-azure package:

Packaging status

Windows

Install with winget:

winget install hickford.git-credential-azure

Go users

Go users can install the latest release to ~/go/bin with:

go install github.com/hickford/git-credential-azure@latest

Configuration

How it works

Git is cleverly designed to support multiple credential helpers. To fill credentials, Git calls each helper in turn until it has the information it needs. git-credential-azure is a read-only credential-generating helper, designed to be configured in combination with a storage helper.

To configure together with git-credential-cache:

git config --global --unset-all credential.helper
git config --global --add credential.helper "cache --timeout 21600" # six hours
git config --global --add credential.helper azure
# to also use git-credential-oauth
git config --global --add credential.helper oauth

You may choose a different storage helper such as osxkeychain, wincred or libsecret, but git-credential-azure must be configured last. This ensures Git checks for stored credentials before generating new credentials.

Windows users are recommended to use storage helper wincred.

Manual config

Edit your global git config ~/.gitconfig to include the following lines:

[credential]
	helper = cache --timeout 21600	# six hours
	helper = azure

Browserless systems

On systems without a web browser, set the -device flag to authenticate on another device using OAuth device flow.

[credential]
	helper = cache --timeout 21600	# six hours
	helper = azure -device

Subtleties with multiple users or organizations

If you use more than one user or organization across Azure Repos, make sure that the remote URLs include usernames. This is the default if you copied the URLs from the Azure Repos web interface.

Alternatively, you can set credential.useHttpPath to store separate credentials for each repo:

git config --global credential.https://dev.azure.com.useHttpPath true

Unconfiguration

Run:

git config --global --unset-all credential.helper azure

Development

Install locally with go install ..

Debugging

Use the -verbose flag to print more details:

git config --global --unset-all credential.helper azure
git config --global --add credential.helper "azure -verbose"

See also

  • Git Credential Manager: a Git credential helper that authenticates to Azure Repos (and other hosts)
    • Caveats: no support for Linux arm64
  • git-credential-oauth (sister project): a Git credential helper that authenticates to GitHub, GitLab, BitBucket and other hosts using OAuth