Git Credential Manager supports gitlab.com out the box.
To use on another instance, eg. https://gitlab.example.com
requires setup and configuration:
- Create an OAuth application. This can be at the user, group or instance level. Specify a name and use a redirect URI of
http://127.0.0.1/
. Unselect the 'Confidential' option. Set the 'write_repository' and 'read_repository' scopes. - Copy the application ID and configure
git config --global credential.https://gitlab.example.com.GitLabDevClientId <APPLICATION_ID>
- Copy the application secret and configure
git config --global credential.https://gitlab.example.com.GitLabDevClientSecret <APPLICATION_SECRET>
- Configure authentication modes to include 'browser'
git config --global credential.https://gitlab.example.com.gitLabAuthModes browser
- For good measure, configure
git config --global credential.https://gitlab.example.com.provider gitlab
. This may be necessary to recognise the domain as a GitLab instance. - Verify the config is as expected
git config --global --get-urlmatch credential https://gitlab.example.com
git config --global --unset-all credential.https://gitlab.example.com.GitLabDevClientId
git config --global --unset-all credential.https://gitlab.example.com.GitLabDevClientSecret
git config --global --unset-all credential.https://gitlab.example.com.provider
Select an authentication method for 'https://gitlab.com/':
1. Web browser (default)
2. Personal access token
3. Username/password
option (enter for default):
If you have a preferred authentication mode, you can specify credential.gitLabAuthModes:
git config --global credential.gitlabauthmodes browser
Improved support requires changes in GitLab. Please vote for these issues if they affect you:
- No support for OAuth device authorization (necessary for machines without web browser): GitLab issue 332682
- Only domains with prefix
gitlab.
are recognised as GitLab remotes: GitLab issue 349464 - Username/password authentication is suggested even if disabled on server: GitLab issue 349463