6

I recently created a project on gitlab logged with my Github account.

But when cloning the project with gitbash (with my current ssh-key added to the gitlab account) the shell prompts for username/password, entering my username and password from github results in failure on authentication. (also email/password fails)

What I'm doing wrong?

2
  • 1
    Are you sure you are using the ssh url? The SSH URL has the username included and, thus, git won't ask for it. Commented Mar 29, 2016 at 16:30
  • @MrTux your comment should be the Nr. 1 answer. Worked for me! Commented Jun 20, 2018 at 10:13

1 Answer 1

3

Updated as of 4/28/2020 4:00 PM (Philippine Standard Time) to include scopes for private repos.

You need to create an access token from your GitLab account if you not yet set up a password or if protected by 2FA.

  • Login to your GL instance account, as usual.
  • Click your profile picture and select Settings.
  • On User Settings sidebar, click Access tokens.
  • At the Add a personal access token section, give a unique name and, optionally expiration date.
  • Select api only as scope for your new access token. If you're working in private projects, also include read_repository and write_repository scopes. Creating a new access token in GitLab.com
  • Hit Create personal access token and let GitLab generate it for you.
  • Copy the access token. You'll be not able to see it again for security reasons. Instance Admins can help you create API keys, but they'll also see this once. enter image description here

Treat your access tokens like your passwords! Keep your scopes for next access tokens low and only share it with person/people you trust. Because I shared the example token here, any attempts to use it were now triggering errors because I revoked it before I update my answers.

Then, try logging in when using git push.

## Init the local repo
mkdir test-to-connect
cd test-to-connect
git init

## Add your user name and email to Git.
git config --global user.name "Your name"
git config --global user.email "[email protected]"


## Create a new private repo after pushing.
git remote set origin https://your-gl-instance-host.dev/your-username/your-new-project-slug

## Commit
git commit -m "Initial commit"

## Push to GitLab
git push origin
## Username for 'https://your-gl-instance-host.dev': your-username
## Password for 'https://[email protected]' [REDACTED]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.