Storing Github access token in git credential store

Motivation

git operations were prompting the github access token despite having GITHUB_ACCESS_TOKEN environment variable in WSL2 on Windows

Prerequisites

Go through the process of generating the github access token as mentioned in Github login using access token via cmdline blog

Solution

Run the following sequence of steps to seek the help of git's credential store on the machine to store the access token

git config --global credential.helper store

Run the following command, which will wait for the input from user. So it is expected that you will see a waiting prompt and not a completed command.

git credential-store --file ~/.git-credentials store

Essentially you are storing the access token in ~/.git-credentials file on disk

Now update the actual github access token against the username key in the following block and paste it at the waiting command prompt

leave the password= as blank, no need to specify a value

protocol=https
host=github.com
username=<access-token>
password=

Hit Enter twice. This will save the credential and exit the command prompt


If you inspect the credential file, you should see something similar as below

$ cat ~/.git-credentials
https://ghp_XXXXXXXXXXXXXXXXXXXXXXX:@github.com

That's it ! From now on, any git commands shouldn't prompt you for username (github user) and password (access token)

Latest Blogposts

SLURM Demo on AWS Ubuntu EC2 instance

Demo of slurm usage on a single instance of Ubuntu 24.04 EC2 instances on AWS

29 May 2024

SLURM on WSL

Setting up SLURM on WSL

27 May 2024

Introduction to SLURM

Simple Linux Utility for Resource Management (SLURM)

26 May 2024

How to find a linux machine is a VM (Virtual Machine) or a Bare Metal

If you can SSH into a linux machine and want to find out if its baremetal or Virtual Machine

7 November 2023

Token generation for Registering Self Hosted Github Runner via REST API

Explains how to generate a token using github API to be used in turn with Github self hosted runner registration

21 March 2023