Git is a version control system that is used for software development and other version control tasks. As a distributed revision control system it is aimed at speed, data integrity, and support for distributed, non-linear workflows. Git was created by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development.
As with most other distributed version control systems, and unlike most client–server systems, every Git directory on every computer is a full-fledged repository with complete history and full version-tracking capabilities, independent of network access or a central server. Like the Linux kernel, Git is free software distributed under the terms of the GNU General Public License version 2.
1.) Update Your System.
First thing you should do is open your terminal and make sure your system is up to date.
$ sudo apt-get update && sudo apt-get upgrade
2) Install Dependences.
You need to install a few things for the git server to be accessible threw your network. more information can be found at the Git Information page.
$ sudo apt-get install git-core ssh
3) Create Master Git Directory.
Now create the master directory for the repository, we will be using ‘directory’ as the name of our master git directory, you may wish to name this directory something else, just be sure to use ‘.git’ at the end of the directory name.
$ sudo mkdir -p /opt/git/directory.git
4.) Initialize Master Git Directory.
The new directory must now be initialized by git in order to make it available.
$ sudo git init --bare /opt/git/directory.git
5.) Move Into Git Directory.
Now navigate into the Git directory so you may easily setup the group and permissions.
$ cd /opt/git
6.) Create Group.
You need to create a group for git users to have the proper permissions. we are using ‘gitgroup’ as the group name, however you may wish to name this something else for your convenience.
$ sudo groupadd gitgroup
7.) Change Permission.
This will set the permissions of all subdirectories of the git directory.
$ sudo chmod -R g+ws *
8.) Add Group.
This will add the group to the directory allowing all members of the group access to the repository.
$ sudo chgrp -R gitgroup *
9.) Move Into The Directory.
Navigate into the directory that will be shared with all members of the group.
$ cd directory.git
10.) Set Sharing.
Now tell git to share this directory to all users of the group.
$ sudo git config core.sharedRepository true
11.) Create Users.
You need to create a user account for all users that will have access to this Git Server.
$ sudo adduser <username>
12.) Add To Group.
Also add all users that will have access to this Git Server to the group.
$ sudo adduser <username> gitgroup