How to Install and Setup Git on Ubuntu

Published on March 27, 2023 · Updated on March 24, 2023
How to Install and Setup Git on Ubuntu

Git is a widely used version control system for managing source code changes. In this tutorial, we will show you how to install and setup Git on Ubuntu.

Installation Git

Installation apt-get

To install Git we can use the apt package manager. First update the remote repositories and then install git with:

sudo apt update && sudo apt install git

To verify the Git installation you can run the following command:

git --version

This should output the freshly installed git version.

Git Settings

Set your name and email address for Git using the following commands:

git config --global "Your Name"
git config --global "[email protected]"

You can also set other options such as your preferred text editor or merge tool using the git config command. To see a list of available options, run the following command:

git config -l

Clone Github Repository

To clone a repository from Github, navigate to the directory where you want to clone the repository and run the following command:

git clone

Replace username with your Github username and repo with the name of the repository you want to clone.

Create Github Repository

  1. To create a new repository on Github, go to your Github account and click the “+” icon in the top right corner, then select “New repository”.
  2. Give your repository a name and a short description.
  3. Choose whether you want your repository to be public or private.
  4. Click “Create repository”.

Commit and Push to a Github Repository

To push changes to a Github repository, navigate to the local repository directory and use the following commands:

git add .
git commit -m "Commit message"
git push origin main

Replace Commit message with a brief description of the changes you made, and origin and main with the name of the remote repository and branch you want to push to.

You can also pull changes from a Github repository using the following command:

git pull origin main

This will download any changes made to the remote repository and merge them with your local repository.


Congratulations, you have successfully installed and set up Git on Ubuntu. With Git, you can easily manage and track changes to your codebase and collaborate with other developers on Github.

Load Comments