Categories: Linux

Setup and configure Git server on CentOS 6.x

Git is a versioning system developed by Linus Torvalds, the founder of Linux. Git is used my millions of people across the globe. It is a perfect replacement to subversion, another Linux versioning system. In this tutorial we will learn how to setup and configure own Git server on CentOS 6.x.

Git is available in the CentOS default repository. We can install it using the following command.

yum install git

This will install Git along with all its dependencies. Once it is installed we will proceed towards the setup.

It is recommended to provide your name and email address. Following are the commands to set the same.

git config –global user.name “Your Name Here”
git config –global user.email “your_email@example.com”

The configuration changes will be stored in a file in your home directory. It can be seen by any editor or a simple cat command

cat ~/.gitconfig

The output will be something like

[user]
name = Your Name Here
email = your_email@example.com

This information can be also viewed by querying git.

git config –list

Output:

user.name=Your Name Here
user.email=your_email@example.com

If the above details are not filled, then they will be filled automatically.

Now we will create our first Git repository.

1. Logon to the server using root.

2. create a new directory

mkdir /home/git

3. Now we will create our first git directory inside the directory created in step 1.

mkdir first_directory.git

4. Now, we will change the working directory to the newly created directory.

cd first_directory.git/

5. Now it’s time to initialize the directory.

git init

We will now create the initial repository on the client machine.

mkdir example
cd example
git init

Add a file

touch TEST

Now add the new file to the repository.

git add TEST

Commit the changes

git commit

Now, we will add the address of the remote repository

git remote add origin ssh://root@remote_server/home/git/first_directory.git

Now push the commit to the remote repository.

git push origin master

If you wish to setup git server for multiple users and multiple repositories, you may try either gitolite or gitosis.

Nitesh Shah

Share
Published by
Nitesh Shah
Tags: git server

Recent Posts

How to setup first Azure Virtual Machine?

Setting up your first Azure Virtual Machine can be done by following these steps: Create…

1 year ago

How to setup Amazon Cloudfront and S3 to serve static resources

Amazon CloudFront is a content delivery network (CDN) that helps you serve static content such…

1 year ago

Step-By-Step Guide To Setting Up An AWS Application Load Balancer

Step-By-Step Guide To Setting Up An AWS Application Load Balancer Are you looking for a…

1 year ago

How to restore MySQL database from .frm and .ibd files?

MySQL databases often get corrupted due to issues like hardware failure, file system failure etc.…

4 years ago

SQL Server Replication

SQL Server Replication is the process of copying databases from one node to another to…

5 years ago

101 System Admin Tools to make life easy

Here are 101 System Admin tools which make System Admins' life easy.

7 years ago

This website uses cookies.