Using Github access token with submodules
2 min readAug 29, 2021
Since August 31, 2021 Github does no longer accept passwords to authenticate users. Instead, we need to create personal access token.
Once you have generated token, it could be used to checkout repository as
git clone https://{github-access-token}@github.com/account-name/repository-name
However, if your repository contains submodules, cloning them:
git submodule update --init
fails as git wasn’t instructed to use the token:
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/account-name/submodule-name/'
fatal: clone of 'https://github.com/account-name/submodule' into submodule path
To make submodules work, use Github CLI to authenticate git requests:
% gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Paste an authentication token Tip: you can generate a Personal Access Token here https://github.com/settings/tokens The minimum required scopes are 'repo', 'read:org', 'workflow'. ? Paste your authentication token: **************************************** - gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as a-sirenko
Now you can clone the repository using gh and initialize submodules:
gh repo clone account-name/repository-name
git submodule update --init