git-techknowledge.in

How to Setup and Configure Git Server on Ubuntu 24.04

Git is the backbone of modern software development. Originally created by Linus Torvalds (the same mind behind Linux), Git is a powerful distributed version control system that helps teams collaborate efficiently.

While platforms like GitHub or GitLab are popular, sometimes you may want full control over your repositories—for privacy, security, or cost reasons. In such cases, hosting your own Git server is the way to go.

In this guide, I’ll walk you through setting up and configuring a Git server on Ubuntu 24.04, step by step.

Step 1: Update Your Server

Before installing anything, make sure your system is up to date:

sudo apt update && sudo apt upgrade -y

Step 2: Install Git

Now, install Git on your server:

sudo apt install git -y

Check the version to confirm installation:

git --version

Step 3: Create a Git User

It’s a good practice to create a separate user just for managing Git repositories:

sudo adduser git

Switch to this user:

su - git

Step 4: Create a Bare Repository

A bare repository is a special type of repo that stores only the project history—no working files. This makes it perfect as a central hub.

mkdir myproject.git
cd myproject.git
git init --bare

This is the repository your team will push to and pull from.

Step 5: Configure SSH Access

For secure communication, we’ll use SSH authentication.

On each developer’s computer, generate an SSH key if they don’t already have one:

ssh-keygen -t ed25519 -C "your_email@example.com"

Copy the public key to the Git server:

ssh-copy-id git@your_server_ip

Now, developers can connect securely to the Git server.

Step 6: Clone and Push Code

Developers can now clone the repository:

git clone git@your_server_ip:/home/git/myproject.git

To push code:

git add .
git commit -m "Initial commit"
git push origin main

Step 7: Secure and Manage Your Git Server

A few best practices to keep things safe and organized:

  • Use a firewall and allow only SSH access.
  • Keep Git and your server updated.
  • Create separate repositories for different projects.

Final Thoughts

Setting up your own Git server on Ubuntu 24.04 gives you complete control over your code, security, and access. It’s an excellent choice for startups, small teams, or anyone who wants independence from third-party platforms.

👉 If you’re new to Linux, you may also like our guide on Essential Linux Commands for Beginners.
👉 For deeper Git features, check out the official Git documentation.

👉for read more article click on give link – techknowledge.in

Leave a Comment

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