Setup Git and Github on a New Computer

Install Git

Mac/ Linux

  • macOS
brew install git
  • Linux/ Unix

Example Using Ubuntu:

sudo apt install git -y

Windows

Download Git installer for Windows

Download from git-scm.org

Install Git on Windows

Skipped.

Git Config

Open Terminal (or git bash on windows) and type :

git config --global user.name "Azat"

git config --global user.mail "[email protected]"

Add SSH to Github

Step 1. Check for Existing SSH Keys

ls -al ~/.ssh

If found have files like :

  • id_rsa.pub
  • id_ecdsa.pub
  • id_ed25519.pub

image-20200803170609093

Then it means we already have ssh keys and we do not have to generate new ons and can skip to the step 3 directly.

image-20200803170620649

If we do not have those files, then we need to go to Step 2 and continue.

Step 2. Generate New SSH Keys (If Not Exists in Step 1)

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Step 3. Add SSH Keys to the ssh-agent

eval "$(ssh-agent -s)"

ssh-add -K ~/.ssh/id_rsa

Step 4. Copy and add the SSH key to Github Settings:

Open Github Settings

Github Settings

Clone SSH Key from the Local machine

macOS:
pbcopy < ~/.ssh/id_rsa.pub
Windows:
clip < ~/.ssh/id_rsa.pub
Linux:
sudo apt-get install xclip -y

xclip -sel clip < ~/.ssh/id_rsa.pub

Step 5. Paste the SSH Key to Github

image-20200803171239584

image-20200803171248287

Test SSH Connection With Github

image-20200803171417741

image-20200803171442669