Use of private gitlab with vscode

Problem to solve

  • achieve to connect vscode with gitlab from a private entity and not gitlab.com

At the university we have a private gitlab eg. https://gitlab-research.university.eu/ and I want to link it with my vscode so I can pull and push directly from there using the gitlab workflow extension.

Some months ago after a complete day of searching and testing different ‘tutorials’ I successfully got it work, but now my PAT personal token credential expired and I am not able to find how to set a new one.
is there any complete guide on setting up vs code with a private gitlab? I have found a lot over youtube and other pages but for gitlab.com which brought me a lot of problems as they were not working as it was trying to connect to gitlab.com.

I remember that once I found the guide to do it, it was quite simple and easy but for the love of god i can not find it again… so, I would appreciate a guide from zero (after installing vs code and created the gitlab account and not only changing the PAT as some colleagues needs to set it also and we would like to do it together.)

thanks in advance.

  1. Create a new PAT in your private GitLab instance, Preference > Access Tokens https://gitlab-research.university.eu/-/user_settings/personal_access_tokens

    • Review which token scopes you will need. I use api, write_repository for example.
  2. Open the command palette in VS Code cmd shift p > search for gitlab > GitLab: Add account to VS Code.

  3. URL to GitLab instance: https://gitlab-research.university.eu/

  4. Add PAT

If you are unsure about used accounts, or need to remove an expired PAT, you can also select GitLab: Remove Account from VS Code and review the list.

The setup is also documented in GitLab Workflow - Visual Studio Marketplace

3 Likes

Hello,
thanks for the explication,
I didnt got any errors while doing the steps you mentioned but I am getting an error (when I try to pull) in the git log:

2024-04-05 15:07:30.153 [info] > git log --oneline --cherry WorkingCase...WorkingCase@{upstream} -- [1ms]
2024-04-05 15:07:30.954 [info] > git pull --tags origin WorkingCase [791ms]
2024-04-05 15:07:30.954 [info] fatal: No credential store has been selected.

Set the GCM_CREDENTIAL_STORE environment variable or the credential.credentialStore Git configuration setting to one of the following options:

  secretservice : freedesktop.org Secret Service (requires graphical interface)
  gpg           : GNU `pass` compatible credential storage (requires GPG and `pass`)
  cache         : Git's in-memory credential cache
  plaintext     : store credentials in plain-text files (UNSECURE)

See https://aka.ms/gcm/credstores for more information.

fatal: No credential store has been selected.

Set the GCM_CREDENTIAL_STORE environment variable or the credential.credentialStore Git configuration setting to one of the following options:

  secretservice : freedesktop.org Secret Service (requires graphical interface)
  gpg           : GNU `pass` compatible credential storage (requires GPG and `pass`)
  cache         : Git's in-memory credential cache
  plaintext     : store credentials in plain-text files (UNSECURE)

See https://aka.ms/gcm/credstores for more information.

Hmmmm I have not seen this specific error yet, but a Google search for gitlab vs code git pull fatal: No credential store has been selected. points to missing Git credential helper setup.

This looks like a Windows system. The link also highlights that Git will use the Windows Credential Manager by default. Seems that this setting is not configured in your Git client (anymore?).

You can inspect that in a new terminal with

git config --global credential.helper

On macOS, I have set it to the osxkeychain (you can see my full .gitconfig here).

git config --global credential.helper osxkeychain 

On Windows, it should work by setting this to the wincred credential helper.

git config --global credential.helper wincred

On Linux, store should work, too.

git config --global credential.helper store

You might get prompted for username/password once on git clone. Add your username, and PAT (not your account password!) into the forms, when asked. Confirm to always use the credential helper.

my bad, i didnt clarify that I was in linux.
emmmm doing
git config --global credential.helper
I am getting
/usr/local/bin/git-credential-manager
but looks like it is a binary file as if I cat it (outside of making my terminal explode of the length of the file ^^) it is all symbols.
if in the other side I do:

git config --global credential.helper store
warning: credential.helper has multiple values
error: cannot overwrite multiple values with a single value
       Use a regexp, --add or --replace-all to change credential.helper.

You might get prompted for username/password once on git clone . Add your username, and PAT (not your account password!) into the forms, when asked. Confirm to always use the credential helper.

not sure what you mean, when I should get this prompted? the username vs code didn’t asked me, as your case in the first post, it asked me the utl and the PAT only. (and I remove the accounts before doing it.

It seems that Git does not complain about the helper itself, but the storage credential.credentialStore. After re-reading the docs in git-credential-manager/docs/credstores.md at main · git-ecosystem/git-credential-manager · GitHub I see it:

GCM comes without a default store on Linux distributions.

I’m not sure what to suggest, but the freedesktop.org Secret Service looks the most secure and easy. git-credential-manager/docs/credstores.md at main · git-ecosystem/git-credential-manager · GitHub I would try that if I had a Linux desktop.

git config --global credential.credentialStore secretservice

This is also what the git log suggested earlier.

Ignore that for now when testing. In case you see a password prompt in the future, this might help.

2 Likes

yup after it promped a window asking for logging. hope that it is stored and it doesn’t repeat each time…(which arrived to me a lot with other apps and also vscode )
thanks in any case :slight_smile:
regards,

1 Like