How To Clone a Git Repository Using Personal Access Token: A Step-by-Step Guide

Ketan Gupta
3 min readJul 14, 2023

Introduction: Cloning a Git repository is a fundamental skill for developers and enables collaboration on projects. In this tutorial, we will guide you through the process of cloning a Git repository using a Personal Access Token (PAT), Let’s dive in!

Step 1: Generate a Personal Access Token (PAT)

  1. Visit your Git hosting platform (e.g., GitHub, GitLab, Bitbucket) and log in to your account.
  2. Click on the profile picture in the right-hand menu, then SETTING > DEVELOPER SETTINGS. (OR CLICK HERE )
  3. Click on the “Generate New Token” or “Create Token” button.
  4. Provide a meaningful name to identify its purpose and select the required permissions based on your intended usage. For cloning repositories, the “repo” or “read” permissions are typically sufficient.
  5. Click on the “Generate Token” button to generate your PAT.
  6. Copy the generated token to your clipboard. Remember that PATs are sensitive and should be treated like passwords.
navigate to the settings page.
developer settings

Make note of the token because once you close the window you won’t be able to view the token again!

Step 2:

Open Your Terminal or Command Prompt Ensure that Git is installed and properly configured on your local machine. Open your preferred terminal or command prompt.

Step 3:

Navigate to the Directory Where You Want to Clone the Repository

Step 4:

Clone the Repository Using the Personal Access Token Execute the following command, replacing <PAT> with your copied Personal Access Token, and <repository-url> with the URL of the Git repository you wish to clone:

git clone https://<PAT>@github.com/username/repo.git

If this does not work you can use:

Copy repo link from here
git clone https://github.com/username/repo.git
username : <yourusername>
password : <PAT generated in step 1>

Repository Cloned Successfully If all the steps were followed correctly, the repository will start cloning to your local machine. Progress will be displayed in the terminal, and once completed, you will have a local copy of the Git repository.

--

--

Ketan Gupta

Blockchain enthusiast and writer exploring crypto, NFTs and decentralized tech. Providing fresh perspectives and thought-provoking insights. Follow for more.