Friday 6 March 2020

Git Installation and Configuration [Windows]

Install https://git-scm.com/download/win

Steps:-

[1]
Github - Profile settings - SSH and GPG keys

[2]
Checking for existing SSH keys - 
Before you generate an SSH key, you can check to see if you have any existing SSH keys.

Open Git Bash.

Enter ls -al ~/.ssh to see if existing SSH keys are present:


$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist

Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:


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

If you don't have an existing public and private key pair, or don't wish to use any that are available to connect to GitHub, then generate a new SSH key.

If you see an existing public and private key pair listed (for example id_rsa.pub and id_rsa) that you would like to use to connect to GitHub, you can add your SSH key to the ssh-agent.

[3]
Generating a new SSH key and adding it to the ssh-agent

After you've checked for existing SSH keys, you can generate a new SSH key to use for authentication, then add it to the ssh-agent.

If you don't already have an SSH key, you must generate a new SSH key. If you're unsure whether you already have an SSH key, check for existing keys.

Generating a new SSH key
Open Git Bash.

Paste the text below, substituting in your GitHub email address.


$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
This creates a new ssh key, using the provided email as a label.


> Generating public/private rsa key pair.
When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.


> Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]
At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".


> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

[4]

Copy SSH key to clipboard from git bash
$ clip < ~/.ssh/id_rsa.pub

[5]

New SSH key
Add Title and Key

[6]

Git global setup
git config --global user.name "name"
git config --global user.email "email"

You are done