Today, in this article, we show how to to define up Private Git Server on Linux. Git is a DevOps tool for managing source code. It is a version control system that can efficiently manage small to very large projects and is free and open source. Git is a tool used to record changes to source code, allowing multiple engineers to collaborate on non-linear development. Git was developed in 2005 by Linus Torvalds for Linux kernel development.
The most popular version control program is called Git. Git keeps track of changes made to files so you have a record of what was made and can roll back to specific versions if needed. Git also facilitates cooperation by allowing you to merge edits from multiple contributors into a single repository. So Git will be useful to you if you develop code that only you will see or work with as a team. Software installed locally is called Git. Your computer stores your files and your historical information.
You can also save a copy of the files and their revision history on Internet servers (such as GitHub or Bitbucket). You can cooperate with other developers more simply if you have a central place where you can publish your changes and download other people’s changes. Two people can even work on different sections of the same file and then merge those changes without losing each other’s work because Git can automatically merge the changes. Below are the steps to set up Private Git Server on Linux.
steps to define up Private Git Server on Linux
Step 1: installing Git on your server is first.
Step 2: If you are using Debian or Ubuntu, run the following commands as sudo user to update the local package index and install git:
sudo apt update && sudo apt install git
Step 3: Type the following command to install the git package on CentOS servers:
sudo yum install git
Step 4: Enter the following command to install the Git package on CentOS servers:
sudo useradd -r -m -U -d /home/git -s /bin/bash git
Step 5: /home/git it belongs to the user home directory. This directory will house all repositories. We did not create a password for the user “git”, then we will have to trust the ssh keys to enter.
Step 6: Using the your command, change to user “git“:
sudo su – git
Step 7: Run the following commands to create the SSH directory and set the correct permissions :
mkdir -p ~/.ssh && chmod 0700 ~/.ssh
Step 8: Create a file called /.ssh/authorized_keys to store SSH keys for authorized users:
tap ~/.ssh/authorized_keys && chmod 0600 ~/.ssh/authorized_keys
Step 9: That’s all there is to it. Server setup is complete. Now you can start working on your own Git repository. To create a new empty repository, run the following command:
git init –bare ~/projectname.git
Step 10: You are free to name the directory however you like. The most critical step is to define up the repository in “git” users home directory.
Result
Empty Git repository initialized to /home/git/projectname.git/
Final words
We hope you like our article on how to to define up Private Git Server on Linux. You can create your own git server on a VPS to store your work and serve as a master repository for any contributor if you want to set up source control for a project, but I’d rather not put it on a site like GitHub. It’s much more private to run your own server, especially if you’re working on code that you don’t want to save to someone else’s “cloud.” While hosting everything yourself might give some people peace of mind, solutions like GitLab are safe.