Cloning Repository from Github portal using PAT

Introduction

The ideal way to clone the Github repository to your local folder is to use PAT (Personal Access Token). Why PAT? It is the most secure and reliable, and most industries are now following this approach. More about PAT can be found in the references section.

Step 1. Login to Github https://www.github.com  with your user ID and password.

Step 2. On successful login click on “Settings” on the top left side of your profile icon.

Settings

Step 3. In the left side option on the next page, you will see the “Developer Settings” in the bottom left.

Developer setting

Step 4. Under the “Github Apps’ section, click on “Personal Access Tokens”

Personal access tokens

Step 5. On the right side, you will see the option “Generate new token”. Select the option Generate new token (classic).

Generate new token

Step 6. Once selected, make sure to click on the copy button, as the token cannot be seen once the page is passed. Copy the PAT in a secure place.

The above steps conclude the setting up PAT for your Github account.

Cloning the repo using PAT

Please follow the below steps to clone the repo using PAT.

Step 1. Go to the repository that you would like to clone and get the raw link. Let's say, in this case, the Github repository link is https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2.git

Https

And the The access token is abc_KzW2mHd9FUDxG26xJ2B3gZxyz.

Step 2. Reform the Github URL from step 1. In this case, embed the PAT in the URL like https://PAT@GithubLink. In this case, the reformed URL for the Git clone would be

https://[email protected]/Azure-Samples/active-directory-dotnetcore-daemon-v2.git

Step 3. Perform the Git clone from your command prompt to clone the repository to a local folder. On a successful clone, you should see the below message and the file getting downloaded to the respective directory.

Command prompt

Step 4. Validate the path. If you observe the screenshot, I have run the git commands from the path c:\users\vayina1\Desktop\VinayWorkingDocs\VisualStudio.

Command prompt

On going to the path, I could see the repository cloned to a local folder.

Active diectory

Conclusion

Thus, in this article, we have seen what PAT is and how to configure PAT from the Github portal, and how to clone the repository safely using PAT.

References


Similar Articles