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.
Installing Git from PPA
Use the following steps to install Git on the Ubuntu Linux system.
- Install the software-properties-common package on your system, which contains add-apt-repository command
sudo apt install software-properties-common -y
- Add the PPA (Personal Package Archive) to your system by running the following command:
sudo add-apt-repository ppa:git-core/ppa
- Update the package list and install Git by running the following commands:
sudo apt update
sudo apt install git
- 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.
- 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 "[email protected]"
To configure identity for a specific repository, remove
--global
from the above command and run it from your repository directory. - Set your default text editor:
git config --global core.editor vim
Replace “vim” with your preferred text editor.
- 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 "[email protected]"
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.