How to Install and Set Up Git on Ubuntu Linux (Step-by-Step Guide)
Git is the most widely used version control system, essential for developers working on personal or team projects. If you're wondering how to install Git on Ubuntu, this step-by-step guide will help you install Git Ubuntu quickly and configure it properly.
In this guide, you'll learn how to install Git on Ubuntu, run the apt install git command, complete the Ubuntu install Git process, and properly set up Git in Ubuntu.
Step 1: Update Package List
Always update your package list before installing new software. Before installing any new software, it’s a best practice to update your system’s package list. This ensures you get the latest available version of Git from the Ubuntu repositories.
sudo apt updateStep 2: Install Git on Ubuntu
Once the package list is updated, you can install Git on Ubuntu using the official repository with the apt install git command:
sudo apt install git -yThis command completes the Ubuntu install Git process using the default package manager.
The -y flag automatically confirms the installation.
Step 3: Verify Git Installation
After installation, confirm that Git has been installed successfully by checking its version:
git --versionYou should see output similar to:
git version 2.x.xThis confirms Git is installed and ready to use.
The same method also works for most Debian-based systems, making it one of the easiest ways to git install on Linux distributions like Ubuntu.
Step 4: Configure Git Username and Email
Git requires your name and email address to associate commits with you. This is especially important when working with GitHub, GitLab, or Bitbucket.
Set your global username:
git config --global user.name "Your Name"Set your global email address:
git config --global user.email "youremail@example.com"Step 5: Verify Git Configuration
To check that your Git configuration has been saved correctly, run:
git config --listYou should see your username and email listed in the output.
Step 6: Create and Initialize a Git Repository (Test)
To ensure everything works properly, create a test directory and initialize a Git repository:
mkdir git-test
cd git-test
git initIf successful, Git will create a .git directory and display a confirmation message.
If you plan to work with remote repositories on platforms like GitHub or GitLab, it's highly recommended to set up SSH authentication instead of using HTTPS. SSH allows secure communication between your system and the remote server without entering your password every time. Follow our complete step-by-step guide on how to set up SSH in Ubuntu and clone repositories using SSH to configure keys and connect your Git account securely.
Now that you have completed the installation, you can explore essential commands like 'git add', 'git commit', 'git status', and 'git push'. Check out our detailed guide on 10 Basic Git Commands Every Developer Should Know to start using Git effectively in real projects.
Conclusion
You have successfully learned how to install Git on Ubuntu and complete the Git install Ubuntu process using the apt install git command. Now your system is ready for version control, collaboration, and professional development workflows.
