How to git clone via https with personal access token in private project?

I try to git clone from my private-project on gitlab.com to local env.
but authentication failed.

NG case below:

https://oauth2:<my-token>@gitlab.com/<my-account>/<my-project-name>.git

https://<my-user-id>:<my-password>@gitlab.com/<my-account>/<my-project-name>.git

https://gitlab.com/<my-account>/<my-project-name>.git?personal_access_token=<my token>

result copy:

C:\Users\<my-win-account>> git clone https://gitlab.com/<my-account>/<my-project>.git/
Cloning into '<my-project>'...
Logon failed, use ctrl+c to cancel basic credential prompt.
Username for 'https://gitlab.com': <my-account>
Password for 'https://<my-account>@gitlab.com':
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/<my-account>/<my-project>.git/'

my env below:

Windows credential manager’s info was cleared already.

2FA disable/enable is no effect.

readed doc

I read below link, but i can’t find a example for how to clone command line.

Hi @KazYag,

You may want to check this issue note to find help

Best Regards,
Łukasz Korbasiewicz
Support Engineer
GitLab, Inc.

Thanks for your res.

Solution is this below.

  • step1. upgrade git for windows(>=2.14) (*all option is default)
  • step2. git config --global http.sslBackend schannel type in git bash(or git CMD)
  • step3. https://<my-user-id>:<my-pat>@gitlab.com/<my-account>/<my-project-name>.git type in git bash(or git CMD)

My env is under “forward authenticated proxy” for enterprise user.
so, error message is Authentication error, but it’s SSL Certificatite error.

already I tryed to fix ssl error like ssl.verify=false, sslcainfo=some-path/for/ca.
but It’s no efffect.

git config --global http.sslBackend schannel is only solution.
(CA Cert of Proxy is already installed in windows env.)

appendix.

git proxy config is below:

$ git config --global http.proxy http://<username if neccesary>:<password if neccesary>@<your-proxy-hosts>:
<port number if neccesary>
$ git config --global https.proxy http://<username if neccesary>:<password if neccesary>@<your-proxy-hosts>:
<port number if neccesary>

This solution works for me - git - Using GitLab token to clone without authentication - Stack Overflow
git clone https://oauth2:<TOKEN>@gitlab.com:<gitlaburl-repository>

git clone https://<token-name>:<token-value>@<gitlaburl-repository>.git also works

1 Like