Git is a popular version control system that is widely used for tracking file changes and coordinating work among multiple people. In this tutorial, we will show you how to install Git on Ubuntu 22.04 / 20.04 from a PPA (Personal Package Archive) and provide some after-installation steps to set up your Git environment.

Advertisement

Installing Git from PPA

Use the following steps to install Git on the Ubuntu Linux system.

  1. Install the software-properties-common package on your system, which contains add-apt-repository command
    sudo apt install software-properties-common -y 
    
  2. Add the PPA (Personal Package Archive) to your system by running the following command:
    sudo add-apt-repository ppa:git-core/ppa 
    
  3. Update the package list and install Git by running the following commands:
    sudo apt update
    sudo apt install git
    
  4. Verify the installation by checking the version of Git:
    git --version
    

    You should see output similar to this:

    git version 2.XX.X
    

That’s it, Git has been installed on your Ubuntu system.

Configuirng Git Client

Once the Git client has been installed successfully. You may do some initial configuration for the Git environment setup.

  1. Set your username and email address in Git: Setup the Git user details on your machine, which is used as your identity by the Github or other repository providers. To set up a username and email address system-wide, execute the following command. Make sure to change your name and email address with yours.
    git config --gloabl user.name "Your Name"
    git config --gloabl user.email "your@email.com"
    

    To configure identity for a specific repository, remove --global from the above command and run it from your repository directory.

  2. Set your default text editor:
    git config --global core.editor vim 
    

    Replace “vim” with your preferred text editor.

  3. Generate an SSH key and add it to your GitHub account (or any other Git hosting service you are using):
    ssh-keygen -t rsa -b 4096 -C "your@email.com" 
    

    This will generate an SSH key and prompt you to enter a file to save the key. Press Enter to accept the default file location. Then, it will ask you to enter a passphrase. You can either leave it empty or enter a passphrase, depending on your preference.

    You can follow our tutorial to add a new SSH key pair to your GitHub account.

That’s it! You have successfully installed Git on Ubuntu and set up some basic configurations. You are now ready to use Git for version control and collaboration.

Conclusion

By following the steps in this tutorial, you have successfully installed Git on Ubuntu 22.04 / 20.04 and set up some basic configuration. You are now ready to use Git for version control and collaboration. Don’t forget to set your username, email address, and default text editor, and generate an SSH key to use with Git hosting services like GitHub. With these basic setup steps, you can start using Git effectively on your Ubuntu system.

Share.
Leave A Reply


Exit mobile version