Git – Create Remote Repository
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' (1001) ... Adding new user `git' (1001) 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 hackthesec
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.gitHackTheSec HackTheSecTwitter www.hackthesec.co.in
0 comments:
Post a Comment