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

Adding Google Analytics to NuxtJS app

Adding Google Analytics GA4 property to NuxtJS App

2 September 2021

Productive Taskbar Settings missing in Windows 11

Very useful Taskbar Settings goes missing in Windows 11.

6 July 2021

Secureboot + Ubuntu + VirtualBox Signing kernel modules

Set of steps required for dealing with secureboot on Ubuntu where VirutalBox service has issues

9 May 2021

Fixing the postfix error dpkg

Steps to fix the postfix error happening during apt upgrade ubuntu.

21 April 2021

Running a react app on Local Kubernetes cluster on Windows 10

Process and steps for running react app on local k8s cluster using minikube on windows 10

16 March 2021