How to Connect Git Bash to Your GitHub Account: Two Easy Methods

Rahul Sharan
4 min readSep 26, 2023

--

Have you ever wondered how to connect Git Bash with your GitHub account? Don’t worry; it’s not as complicated as it might sound. In this blog post, we will walk you through two simple methods to make this connection: using a personal access token and using your username and personal access token. Whether you’re new to Git or a seasoned pro, these steps are easy to follow.

Method 1: Using a Personal Access Token

Step 1: Generate a Personal Access Token

  1. Log in to your GitHub account.

2. Click on your profile picture in the top-right corner and select “Settings.”

GitHub Settings

3. In the left sidebar, click on “Developer settings.”

Github Developer Settings

4. Now, click on “Personal access tokens” under “Access tokens.”

Click the “Generate token” button.

Provide a token description and select the scopes you need. For Git operations, select at least “repo” and “workflow.”

Scroll down and click the “Generate token” button at the bottom of the page.

Github PAT Token
Generate token

Step 2: Configure Git Bash

  1. Create test repository for credentials.
Test Repo.
Github Repo. URL

2. Open Git Bash on your computer.

Git Bash Terminal

3. Enter the following commands on git bash.

mkdir testfolderforcredentials
cd testfolderforcredentials
git clone 'Your GitHub Repo URL'
ls
cd 'repo name'
vi testfile
cat testfile
git status
git add testfile
git status
git commit -m "this is test file for credentials- 1st method"
git push
Github Sign In

That’s it! You’ve successfully connected Git Bash to your GitHub account using a personal access token.

Method 2: Using Your Username and Personal Access Token

Step 1: Generate a Personal Access Token (if you haven’t already)

Follow the same steps as mentioned in Method 1 to generate a personal access token.

Remove the Github Credentials from windows machine.

Windows Credentials manager

Step 2: Use Git with Your Username and Token

  1. lets move to Git Bash on your computer.

2. Now , lets make some changes in the test file again that we created.

ls -ltr
vi testfile
cat tesfile
git add testfile
git commit -m "This is a test file for testing git credentials - 2nd Method"
git push
GitHub Sign In
Github Username
Github PAT Token

Congratulations! You’ve connected Git Bash to your GitHub account using your username and personal access token.

In conclusion, connecting Git Bash to your GitHub account is essential for managing your repositories and collaborating with others. Whether you prefer using a personal access token or your username and personal access token, these methods will help you get started with ease. Happy learning!

Photo by Ben White on Unsplash

--

--