Install and Configure Git Server On Rocky Linux 8
In this tutorial, we will show the steps to install and configure Git Server On Rocky Linux 8.
Git is a fast, scalable, distributed version-control system for tracking changes in source code during software development. Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
We have covered installation and configuration of the Git Server On Rocky Linux 8.
Prerequisites
- A Rocky Linux 8 installed dedicated server or KVM VPS.
- A root user access or normal user with sudo privileges.
There are two options to install Git.
Option 1 is install Git using DNF
Step 1 – Keep the server up to date
Always keep the server up to date the security purpose.
dnf update -y
Step 2 - Install Git
dnf install git -y
Option 2 is install Git from source
You can download latest version of Git from release page. It make take longer time and will not be updated and maintained through the yum package manager. But it will allow you to download a newer version than what is available through the CentOS repositories, and will give you some control over the options that you can include.
Step 1 - Install dependencies
dnf groupinstall "Development Tools" dnf install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel
Step 2 - Download Git
After the dependencies get installed, go to release page and copy the download link. You can find tar.gz, right click on it and copy the link.
Now, download it in the server using wget command and rename it:
wget https://github.com/git/git/archive/refs/tags/v2.39.2.tar.gz -O git.tar.gz
Once the download is complete, we can extract the tar file
tar zxf git.tar.gz
Now, go to that directory to begin configuring our build.
cd git-*
Step 3 - Run Configure and Install
We can check for everything that we need with the configure script that is generated by make configure. This script will also use a –prefix to declare /usr/local (the default program folder for Linux platforms) as the appropriate destination for the new binary, and will create a Makefile to be used in the following step.
make configure ./configure --prefix=/usr/local
Makefiles are scriptable configuration files that are processed by the make utility. Our Makefile will tell make how to compile a program and link it to our CentOS installation so that we can execute the program properly.
make install
We have built and installed Git successfully. To verify it check the version using following command:
git --version
Finally, Setup Git
Add user to handle the repositories:
useradd git
Set password to the Git user:
passwd git
Log in as a git user
su - git
Initiate a new empty repository using following command:
git init --bare ~/hostnextra.git
Enable post-update hook by copying the sample file as follows:
cd hostnextra.git/hooks/ cp post-update.sample post-update
That’s it for server side.
Now, let’s go to client side:
Install Git
dnf install git -y
The installation is completed
Set up git
Submit inflammation about yourself so that commit messages will be generated with correct information attached:
git config --global user.name "hostnextra" git config --global user.email "[email protected]"
Create a directory where you can keep all your projects
mkdir ~/dev cd ~/dev
Now, create a clone the hostnextra.git repository that we have created earlier in the server.
git clone git@[Server IP]:~/hostnextra.git hostnextra.git
Note: Replace [Server IP] with your server IP or hostname
Go to respository
cd hostnextra.git
You can see the repository is empty, so lets create some files
echo “my test file” > file1.txt
Add these file to our git repository
git add .
Commit the changes
git commit -am "My First Commit"
Output:
[master (root-commit) cb4c46f] My First Commit 1 file changed, 1 insertion(+) create mode 100644 file1.txt
Push these changes to the remote git repository.
git push origin master
You will be asked for password, enter git user password.
[email protected]'s password: Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 240 bytes | 240.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To 192.168.1.16:~/hostnextra.git * [new branch] master -> master
Verify the changes, access the git server and run following command to check the logs.
git log
We have seen, how to install Snipe-IT on Rocky Linux 8. Here is the Git official Documentation.