Git – Create Remote Repository

undefined

In this chapter of Git Tutorial, You will learn how to create remote git repository on remote server which will be used as centralized repository by developers. All the developers needed to make a clone of this repository on their local system to start work. They can also add this to there existing repository to push file to this repository.

1. Create System User

First create a system user, which will be used to connect repository on server from client systems.

$ sudo adduser git 

Adding user `git' ...
Adding new group `git' (1044) ...
Adding new user `git' (1044) with group `git' ...
Creating home directory `/home/git' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: *********
Retype new UNIX password: *********
passwd: password updated successfully
Changing the user information for git
Enter the new value, or press ENTER for the default
	Full Name []:
	Room Number []:
	Work Phone []:
	Home Phone []:
	Other []:
Is the information correct? [Y/n] y

2. Crete Bare Repository

Now create a git bare repository. This repository will be used as remote repository by developers. First we are creating a project directory. After that I will create our first git repository named app1.git inside project directory. Try to keep repository name ending with .git for better naming convention.

$ mkdir project
$ cd project

$ mkdir app1.git
$ cd app1.git

Now use following command to initialize repository. Do not forgot to use –bare keyword in command to create bare repository.

$ git --bare init

Initialized empty Git repository in /home/git/project/app1.git/

If you list files inside repository you will not find directory named .git due to bare repository, You will see their many files like below

$ ls -l

total 32
drwxrwxr-x 2 git git 4096 Oct  8 12:33 branches
-rw-rw-r-- 1 git git   66 Oct  8 12:33 config
-rw-rw-r-- 1 git git   73 Oct  8 12:33 description
-rw-rw-r-- 1 git git   23 Oct  8 12:33 HEAD
drwxrwxr-x 2 git git 4096 Oct  8 12:33 hooks
drwxrwxr-x 2 git git 4096 Oct  8 12:33 info
drwxrwxr-x 4 git git 4096 Oct  8 12:33 objects
drwxrwxr-x 4 git git 4096 Oct  8 12:33 refs

3. Access Repository From Dev PC

Now you can make a clone of this repository from clients system using following command.

$ git clone git@remote.example.com:project/app1.git

If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

One Comment to Git – Create Remote Repository

  1. […] on a project since many days, but still not added this project under Git. Now you have create a remote git repository and want to add your project under […]

Leave a Reply

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