Featured image of post Setup Github With Git using Github CLI

Setup Github With Git using Github CLI

setup github account with git, in Ubuntu, WSL 2 and Windows 11, using Github CLI

Intro

One of the easiest way to connect your Github account with your git installed on Windows is through Github Desktop. But, we can’t use that on wsl, so we use PAT(personal access token) to resolve this issue!

Steps to setup on Windows 11

  1. install git on Windows
  2. install Github Desktop
  3. Login your Github Desktop with your Github account

install git on WSL 2

  1. prerequisites: WSL2, Ubuntu distro
  2. if your Ubuntu distro hadn’t already install git (which in my case is already installed), or you can install it with
1
sudo apt-get install git
  1. check git version with
1
git --version
  1. setup git global config
1
2
git config --global user.email "[email protected]"
git config --global user.name "Your Name"

install Github CLI

  1. download and install Github CLI following this tutorial. In Ubuntu, you can install it with apt.

  2. login in the Github website

1
gh auth login
  1. test: clone, commit and try to push a github repo
1
2
3
4
git clone <repo url>
git add *
git commit -am "commit name"
git push
  1. output example:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
$ git add *
$ git commit -am "init"
[master 563c3a8] init
 1 file changed, 3 insertions(+), 16 deletions(-)
$ git push
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 20 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 608 bytes | 101.00 KiB/s, done.
Total 6 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To https://github.com/ryankert01/blog.git
   af6a1b1..563c3a8  master -> master
Licensed under CC BY-NC-SA 4.0
RyanKert
Built with Hugo
Theme Stack designed by Jimmy