How to Set up the HTTP Git Server for Private Projects – InApps Technology is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn How to Set up the HTTP Git Server for Private Projects – InApps Technology in today’s post !

Read more about How to Set up the HTTP Git Server for Private Projects – InApps Technology at Wikipedia

You can find content about How to Set up the HTTP Git Server for Private Projects – InApps Technology from the Wikipedia website

You’re a developer. You work on many projects, some of which are collaborated on across the world. Those projects are probably hosted on GitHub, or some other large-scale versioning system. Some of your projects, however, might be small or private enough that you don’t want them hosted on public repositories. Those projects might be proprietary or only intended for internal usage.

For those projects, what do you do?

One possibility is the HTTP Git Server. This open source project uses NGINX to serve up Git repositories over your Local Area Network (LAN). HTTP Git Server is surprisingly easy to setup and manage.

I’m going to walk you through the process of installing and configuring HTTP Git Server on Ubuntu 18.04. Once complete, you’ll have a repository that anyone on your LAN can use.

What You’ll Need

In order to successfully get HTTP Git Server up and running, you’ll need the following:

  • A running instance of Ubuntu Server 18.04.
  • A user with sudo privileges.

That’s it. Let’s get your git repos up and running.

Update and Upgrade

The first thing you’ll want to do is update and upgrade your instance of Ubuntu server. Remember, however, if the kernel is upgraded in the process, you’ll need to reboot the server. Because of this, make sure to run the update/upgrade at a time when a reboot is possible.

Read More:   Data Sharing Key to Success for COVID-19 Data Models – InApps 2022

Log into your Ubuntu server and update apt with the command:

sudo apt-get update

Once apt is updated, upgrade the server with the command:

sudo apt-get upgrade -y

When this completes, reboot the server (if necessary).

Installing Dependencies

You can install everything necessary for HTTP Git Server with a single command. Go back to the terminal and issue:

sudo apt-get install nginx git nano fcgiwrap apache2-utils -y

That’s all there is to the installation of software on your server.

Create a Git Directory to House Repositories

With everything installed, create a directory to house our Git repositories with the command:

sudo mkdir /var/www/html/git

Give that directory the proper ownership with the command:

sudo chown -R www-data:www-data /var/www/html/git

Configure NGINX

NGINX must now be configured, such that it knows to serve up the repositories on the server. To do this, open the default NGINX site configuration file with the command:

sudo nano /etc/nginx/sites-available/default

Look for the following section:

Under that section, paste the following:

Save and close the file.

Run the NGINX configuration test with the command:

sudo nginx -t

You should see the following reported back:

nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

If you do see errors, go back into the configuration file and make sure the above code was pasted in the proper section.

Create a User Account

We now need to create a user that will have access to the HTTP Git Server. We’ll do this by way of the htpasswd command. I’ll demonstrate by creating the user “jack.” You’ll want to make sure to create a user specific to your needs.

To create the new user, issue the command:

sudo htpasswd -c /var/www/html/git/htpasswd jack

You’ll be prompted to type and verify a new password for the user. Once that’s complete, restart NGINX with the command:

sudo systemctl restart nginx

Create Your First Repository

It’s time to create your first repository. Since we just created the user, jack, we’ll stick with that. Remember, however, to create a repository using the same name as you did when you created the new user account.

To create the new repository, change into the git directory with the command:

cd /var/www/html/git

Now create the repository with the command:

sudo mkdir jack.git

Change into this new directory with the command:

cd jack.git

Now we’ll initialize the repository with the command:

Read More:   Why Your Next Database Will Be a Serverless API – InApps 2022

sudo git --bare init

Next, we want to update the Git server, so it’s aware of the changes. Issue the command:

sudo git update-server-info

Change the ownership of the new repository with the command:

sudo chown -R www-data:www-data .

Change the permissions of the repository with the command:

sudo chmod -R 755 .

Connect to the Repository

It’s finally time to connect a desktop to the repository. Move to another machine on your network. If that machine doesn’t have git installed, do so now. If the machine is a Linux workstation, you can install git with one of the following commands (first for Debian-based distributions and second for Red Hat-based distributions):

sudo apt-get install git -y

sudo dnf install git

I’m going to demonstrate the next steps on a Ubuntu Linux desktop machine. If you’re using a different platform, some of the steps will vary.

Create a local repository with the command:

mkdir ~/testproject

Change into that new repository with the command:

cd ~/testproject

Initialize the repository with the command:

git init

Add the origin (taken from our HTTP Git Server) with the command:

git remote add origin http://[email protected]_IP/jack.git

Where SERVER_IP is the IP address of the HTTP Git Server hosting server.

Create some test directories and files. First create the directories with the command:

mkdir test1 test2 test3

Next, create test files with the command:

touch test1/testing1 test2/testing2 test3/testing3

We can now add those files to git with the command:

git add .

Commit the changes with the command:

git commit -a -m "Test directories and files added."

Push all of the new content to the server with the command:

git push origin master

Clone the New Repository

With the new repositories uploaded to the server, go to yet another machine on your LAN (one with Git installed) and clone the new repository with the command:

git clone [email protected]_IP:/var/www/html/jack.git

You will be prompted for the user password you created. Upon successful authentication, git will clone the repository and you should see a new directory (in this case, jack) in your current working directory.

That’s all there is to setting up your own Git repository server on your LAN. HTTP Git Server is an outstanding solution for developers looking to host their own repositories. Give this a try and see if it doesn’t wind up your goto choice for local Git hosting.

Feature image via Pixabay.

Source: InApps.net

5/5 - (1 vote)
As a Senior Tech Enthusiast, I bring a decade of experience to the realm of tech writing, blending deep industry knowledge with a passion for storytelling. With expertise in software development to emerging tech trends like AI and IoT—my articles not only inform but also inspire. My journey in tech writing has been marked by a commitment to accuracy, clarity, and engaging storytelling, making me a trusted voice in the tech community.

Let’s create the next big thing together!

Coming together is a beginning. Keeping together is progress. Working together is success.

Let’s talk

Get a custom Proposal

Please fill in your information and your need to get a suitable solution.

    You need to enter your email to download

      [cf7sr-simple-recaptcha]

      Success. Downloading...