Git and Github on Linux - Install and configure (easy)
Tags: tutorial, github, git, beginners
Published: 2023-05-24 23:46:23

In this tutorial, I will walk you through the process of installing Git on your Linux system and configuring it to work with GitHub.

Step 1: Open the Terminal

- To start, open the Terminal on your Linux computer. You can usually find it in the Applications or System Tools menu.

Step 2: Check if Git is already installed

- Type the following command in the Terminal and press 

Enter:

```
git --version
```

- If Git is already installed, you will see the version number. If not, you will need to install it.

Step 3: Install Git

- In the Terminal, enter the appropriate command based on your Linux distribution:

For Debian/Ubuntu:

```
sudo apt-get update
sudo apt-get install git
```
For Fedora:

```
sudo dnf install git
```
For CentOS/Red Hat:
```
sudo yum install git
```

Step 4: Configure Git

- After Git is installed, you need to configure it with your name and email address. In the Terminal, enter the following commands, replacing "Your Name" with your actual name and "your.email@example.com" with your email address:

```
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
```

Step 5: Generate SSH Key (optional)

- If you plan to use SSH for secure communication with GitHub, you can generate an SSH key. This step is optional, but it provides convenience and security.
- In the Terminal, enter the following command, replacing "your.email@example.com" with your GitHub email address:
```
ssh-keygen -t ed25519 -C "your.email@example.com"
```
-Press Enter to accept the default location and enter a passphrase when prompted (you can leave it empty for no passphrase).

Step 6: Add SSH Key to GitHub (optional)

- If you generated an SSH key in the previous step, you can add it to your GitHub account for authentication.
- In the Terminal, enter the following command to copy your public key to the clipboard:

```
xclip -sel clip < ~/.ssh/id_ed25519.pub
```

- Go to the GitHub website (https://github.com) in your browser, log in to your account, and follow these steps:
   - Click on your profile picture in the top-right corner and select "Settings".
   - In the left sidebar, click on "SSH and GPG keys".
   - Click on the green "New SSH key" button.
   - Give your key a meaningful title (e.g., "Linux Laptop") and paste the key into the "Key" field.
   - Click on the green "Add SSH key" button.

Step 7: Test the connection (optional)

- If you added an SSH key to your GitHub account, you can test the connection to make sure it works.
- In the Terminal, enter the following command:
```
ssh -T git@github.com
```
- You should see a message that says "Hi [your username]! You've successfully authenticated..."

Step 8: Link GitHub account to Git
- Now that Git is installed and configured, you can link it to your GitHub account.
- In the Terminal, enter the following command, replacing "username" with your GitHub username:

```
git config --global github.user username
```

That's it! 

Remember to replace any placeholder information with your own details when following the tutorial.

If you need help on how to use Git and Github, I have a tutorial on how to use basic functions [Here](https://dev.to/vlythr/using-git-and-github-basic-funtions-easy-3ig5)