Access a Git Repository Using Token-Based Authentication

You can use an authentication token that has been generated in VB Studio instead of your password to access a Git repository.

Note:

If you have user rights to read and write to Git for all projects you are a member of, you can create a token using the All User Rights option; however, be aware that any token with this scope won't provide a user with the ability to create/delete tokens or modify any other profile preferences settings.
  1. From your VB Studio preferences, generate an authentication token for your project with both Read and Write Git permissions. See Set Up Token-Based Authentication.
  2. Open the Git client.
  3. Navigate to the directory where you want to clone the remote Git repository.
    If the directory into which you want to clone the repository isn't empty, you'll need to create a new subdirectory and clone the repository into it. You can only perform a cloning operation into an empty directory.
  4. Using the Git client, clone the project’s Git repository.

    For example, if you’re using the Git CLI, enter the following git clone command. You'll be prompted to enter your username and password. When prompted for your password, enter your personal access token instead of a password.

    
    git clone https://myinstance.com/organization_name>/s/<project_name>/scm/<repo_name>.git
    Username: YOUR_USERNAME
    Password: YOUR_PERSONAL_ACCESS_TOKEN

    You could also enter a command like this, using the username and token in a git clone command with this format:

    git clone https://<username>:<personal_access_token>@https://myinstance.com/organization_name>/s/<project_name>/scm/<repo_name>.git

    You could even enter a command like this, using just the token in a git clone command with this format:

    
    git clone https://<personal_access_token>@https://myinstance.com/organization_name>/s/<project_name>/scm/<repo_name>.git

    Tip:

    Use <username>:<personal_access_token> if the specified user owns the token. If the user doesn't own the token, an Auth error will be encountered.

    Use just <personal_access_token> when the user is the one who owns the token.

  5. Commit the updated files to the cloned Git repository.
  6. Push the commit from the cloned Git repository to the hosted Git repository, using a command like this example shows:
    
    
    git push origin main

    The username and token from the git clone command may be cached, so you may not be prompted for them. If you are, enter the token for the password, as you did previously.