Github login using access token via command line

Motivation

Solution

Run the following sequence of steps to figure out the solution

  • First Go to Github Tokens for your account
  • Then hit on Generate new token

    • Give appropriate Note for identifying it at a later date
    • Select proper Expiration time => You will need to regenerate your token after expiration
    • Select OAuth scopes as per requirement
    • Hit Generate Token at the end image

Note down the generated token as it won't be shown again, in a secure place

Now get back to command line (in my case PowerShell)

  • Make sure to check the email/username configured with git commandline global settings

    git config --global user.name
    git config --global user.email
    
  • Set the values accordingly, if they are not as intended

    git config --global user.name "your_github_username"
    git config --global user.email "your_github_email"
    
  • One can check all the config values by running the following

    git config -l
    git config -l --global  # shows only global config values
    
  • Set credential helper timeout to probably few hours or a day, so as to avoid the prompt for login on every git push/git pull command

    git config --global credential.helper "cache --timeout=86400"
    
  • Run git pull while at the root of the existing cloned repository

    Username for 'https://github.com' : username
    Password for 'https://github.com' : paste your personal token from earlier step here
    

You should all be setup until the timeout happens and the prompt appears again

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

Storing Github access token in git credential store

Using git credentials store the github access token to avoid the re-prompting of username and pwd

4 April 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