Skip to content

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 “[email protected]

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 = [email protected]

This information can be also viewed by querying git.

git config –list

Output:

user.name=Your Name Here
[email protected]

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.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security