This article will tell you how to install and config git.

1.Install Git

For the latest stable version for your release of Debian/Ubuntu.

$ apt-get install git -y

If it is installed successfully ,you use command git --version and you will see the version.

2.First-Time Git Setup

2.1 Set your identity

If you pass the –global option ,you need to do this only once because then Git will always use that information for anything you do on that system.
If you want to override this with a different name or email address for specific projects, you can run the command without the –global option when you’re in that project.

$ git config --global "John Doe"
$ git config --global [email protected]

2.2 Set your editor

Now you can configure the default text editor that will be used when Git needs you to type in a message.
If not configured, Git uses your system’s default editor.
If you want to use a different text editor, such as Emacs, you can do the following:

$ git config --global core.editor emacs

2.3 Checking Your Settings

If you want to check your configuration settings, you can use the git config –list command to list all the settings Git can find at that point:

$ git config --list Doe
[email protected]

You can also check what Git thinks a specific key’s value is by typing git config :

$ git config
John Doe

3.Connecting to GitHub with SSH

3.1 About SSH

Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username or password at each visit.

3.2 Checking for existing SSH keys

By default, the filenames of the public keys are one of the following:

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

3.3 Generating a new SSH key

Open Terminal ,and paste the text below, substituting in your GitHub email address.

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

3.4 Adding a new SSH key to your GitHub account

① Copy the SSH key to your clipboard

Your ssh file is saved as ~/.ssh/ ,such as
You can open your ssh file ,and copy the text to your clipboard.

② Adding the SSH key to your GitHub account

In the “Title” field, add a descriptive label for the new key.
Paste your key into the “Key” field.

3.5 Testing your SSH connection

Open Terminal ,and paste the text below.

$ ssh -T [email protected]

If your SSH connection is ok ,you will see a message like this:

Hi username! You've successfully authenticated, but GitHub does not
provide shell access.


Connecting to GitHub with SSH
Git - Book