How to Install and Configure Git and GitHub on Ubuntu (Linux)

How to Install and Configure Git and GitHub on Ubuntu (Linux)

Step-by-Step Guide to Installing and Configuring Git & GitHub on Ubuntu

ยท

2 min read

Step 1: Update Your System

Before installing any software, it's a good practice to update your package list to make sure you're installing the latest version available in the repository.

  1. Open the terminal on your Ubuntu system.

  2. Run the following command to update your system:

     sudo apt update
    

    This will fetch the latest package list from the repository.

Step 2: Install Git

Now that your package list is up to date, you can install Git using the following command:

  1. Install Git by running:

     sudo apt install git
    
  2. After entering the command, you may be prompted to confirm the installation. Press Y and hit Enter to proceed.

Step 3: Verify the Installation

Once the installation is complete, verify that Git is installed correctly.

  1. Check the Git version by running the following command:

     git --version
    

    This should output the version of Git that was installed, something like:

     git version 2.x.x
    

Now that Git is installed, it's a good idea to set up your Git identity (your name and email). This will be used in commit messages.

  1. Set your name:

     git config --global user.name "Your Name"
    
  2. Set your email address:

     git config --global user.email "youremail@example.com"
    

These commands set your global configuration, meaning that Git will use this information for all your repositories. If you want to configure it differently for a specific project, you can do so later within that project's directory.

Step 5: (Optional) Set Up SSH Keys for GitHub or Remote Repositories

If you plan to work with GitHub or other Git hosting services, setting up SSH keys can simplify authentication.

  1. To generate an SSH key pair, run:

     ssh-keygen -t rsa -b 4096 -C "youremail@example.com"
    
  2. Follow the prompts to create the key pair and save it in the default location (/home/yourusername/.ssh/id_rsa).

  3. After the key is generated, you can add the SSH key to your GitHub or GitLab account.

Step 6: Done!

You have successfully installed and configured Git on your Ubuntu system. You can now start using Git to manage your code repositories!

Follow my Blog for regular and interesting updates
and sign up for our upcoming YouTube channel ยป
Support Awstronaut โ˜๏ธ๐Ÿš€ - buymeacoffee.com/awstronaut โ˜•๐Ÿ’ป

ย