How to Set Up Git on an Ubuntu Server

How to Set Up Git on an Ubuntu Server

Author: Manoj Damor
Last Updated: October 2025

Git is one of the most powerful tools for version control — used by developers worldwide to manage code efficiently. In this guide, you’ll learn how to set up Git on an Ubuntu server from scratch and configure it for secure usage.


🧩 Step 1: Update Your Server

Before installing Git, it’s always a good idea to update the package list and existing packages.

sudo apt update && sudo apt upgrade -y

Image Suggestion:
A terminal showing the apt update process running.


⚙️ Step 2: Install Git

To install Git, use the following command:

sudo apt install git -y

Once installed, verify it with:

git --version

You should see output similar to:

git version 2.43.0

Image Suggestion:
Screenshot of terminal showing “git version” output.


👤 Step 3: Configure Your Git User

After installation, configure your Git identity so that every commit is associated with your name and email.

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

You can check your configuration with:

git config --list

Image Suggestion:
Terminal showing configured user name and email.


Using SSH keys allows you to securely connect to services like GitHub, GitLab, or Bitbucket without needing to enter passwords each time.

Run the command:

ssh-keygen -t ed25519 -C "[email protected]"

Press Enter through the prompts to accept defaults. Then, display your public key:

cat ~/.ssh/id_ed25519.pub

Copy this key and add it to your Git hosting provider (GitHub → Settings → SSH and GPG keys → New SSH key).

Image Suggestion:
Screenshot of terminal generating an SSH key and displaying the public key.


📁 Step 5: Clone a Repository

Now you can clone a repository to your server.

For public repositories:

git clone https://github.com/username/repo-name.git

For private repositories (using SSH):

git clone [email protected]:username/repo-name.git

If you’re using a fine-grained personal access token, the command looks like this:

git clone https://<YOUR_TOKEN>@github.com/username/repo-name.git

(Replace <YOUR_TOKEN> with your actual GitHub personal access token.)

Image Suggestion:
Terminal showing a Git repository being cloned successfully.


🧰 Step 6: Basic Git Commands

Here are a few useful Git commands to get started:

CommandDescription
git statusCheck the status of changes
git add .Stage all changes
git commit -m "message"Commit staged files
git pushPush commits to remote repo
git pullFetch and merge changes from remote repo

Image Suggestion:
Terminal showing git add, commit, and push sequence.


✅ Step 7: Verify Your Setup

Run this command to confirm everything is working properly:

ssh -T [email protected]

You should see a success message like:

Hi username! You've successfully authenticated.

Image Suggestion:
Terminal showing successful SSH connection to GitHub.


🎯 Conclusion

You’ve now successfully set up Git on your Ubuntu server!
You can securely clone, push, and manage your repositories directly from the command line.

This setup is ideal for web developers, DevOps engineers, and teams managing server-side codebases.


👉 Bonus Tip:
If you’re managing multiple Git accounts or deploying apps, consider using SSH config files to handle multiple keys easily.


Tags: #Git #Ubuntu #DevOps #ServerSetup #Linux
Author: Manoj Damor – Tech Blogger & Developer


Leave a Reply

Your email address will not be published. Required fields are marked *