Setting a git server in local area network

Reading Time: < 1 minute

In this blog, we will learn to setup a git server in a system which will be accessible over the local area network.

First we have to setup SSH server to the system(Git Server), to provide access to other (git client) system. We will do this to get access to our git server, so git client will be able to push and pull code to git server. Both server and client have to install git as well.

Now create a user called ‘gitserver’ in Server and make sure clients can access this user without password.

Note: In this blog git server’s IP is 192.168.2.137 and client’s IP is 192.168.2.129.

Configurations at Server Side:

$ su gitserver
$ cd /opt/git
$ mkdir project.git
$ cd project.git
$ git init --bare

Note: This is to initialize empty Repository in /opt/git/project.git directory.

Configurations at Client Side:

$ cd project
$ git init
$ git add.
$ git commit -m "Initial Commit"
$ git remote add origin gitserver@192.168.2.137:/opt/git/project.git
$ git push origin master

Now other clients can simply clone the git by the following command:

$ git clone gitserver@192.168.2.137:/opt/git/project.git

The repository will be there in your system.

2 thoughts on “Setting a git server in local area network1 min read

Comments are closed.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading