As precondition, it is important clarify the following definition:
A server repository, also called "bare repository", is a Git repository without a working copy.
Git can use four protocols to transport data:
- Local;
- Secure Shell (SSH);
- Git;
- HTTPS.
For
all protocols, we have to create the bare repository by executing these
lines on the server's command lines. With the following commands, you
can create a directory myproject and initialize an empty Git bare
repository. Create the directory and go inside it:
$ mkdir myproject
$ cd myproject
Initialized empty Git repository in /home/user/myproject:
$ git init --bare
Local protocol
The
local protocol is the basic protocol; the remote repository is a local
directory. This protocol is used if all members have access to the
remote repository. Now, every programmer has to clone it in local:
$ git clone /opt/git/myproject.git
For
example one of the programmers, has already written some code lines. He
has to initialize a local Git repository inside the directory and set a
remote location for the bare repository:
develper@local$ git init
develper@local$ git remote add origin /opt/git/myproject.git
This example will be reported for each protocol. To identify it will be called "example of developer".
The following are the pros of the local protocol:
- Easy to share with other members.
- Fast access on the repository.
And the cons are:
- Hard to set up a shared network.
- Fast only if the file access is fast.
SSH
Secure
Shell (SSH) is the most used protocol, especially if the remote
repository is on a remote server. Now, every programmer has to first
clone it in local:
$ git clone ssh://username@server/myproject.git
Using
the SSH protocol, programmers have to install their SSH keys on the
remote repository in order to push to and pull from it. Otherwise, they
have to specify the password on each remote command.
The example of developer in this scenario:develper@local$ git init
develper@local$ git remote add origin ssh://username@server/myproject.git
The following are the pros of the ssh protocol:
- Easy to share using a remote server.
- SSH compresses data while transport, which makes it fast.
- No anonymous access.
Git
The Git transport is similar to SSH, but without any security. You can't push data on it by default, but you can activate this feature. Like in all cases, the programmer has to clone it in local, as follows:$ git clone git://username@server/myproject.git
develper@local$ git init
develper@local$ git remote add origin git://username@server/myproject.git
- Faster than the others.
- No security because the Git transport is the same as SSH but without the security layer.
HTTPS
The
HTTPS protocol is the easiest to set up. Anyone who has access to the
web server can clone it. The programmers start to clone it in local:
$ git clone https://server/myproject.git
develper@local$ git init .
develper@local$ git remote add origin http://server/myproject.git
- Easy to set up.
- Very slow data transport.
No comments:
Post a Comment