Introduction#
The most famous Git server is Github Since January 2010, GitHub (On this site the code is stored public and free, although it can also be done privately, by creating a paid account).
A remote repository is usually a minimum basic repository, a Git repository without a working folder. Because such a repository is going to be used exclusively as a collaboration point, it doesn’t make sense to have an active working snapshot on disk (checkout); it’s enough for us to just have the Git data itself. Basically, a minimum basic repository is the contents of the ‘.git’ folder, as is, without anything else.
Why have my own server?#
- Access from anywhere
- Free
- Free Software
- Full control of code and access
- Allows collaborative development (For this it is not essential but highly recommended)
- Everyone will push and get to or from there
Which protocol(s) to choose?#
More info http://git-scm.com/book/es/Git-en-un-servidor-Los-Protocolos
In my opinion, the best is a combination of several of them to provide all kinds of access
How do I install it?#
#CREAMOS LAS CLAVES SSH
cd ~/.ssh
# si no existen id_dsa y id_dsa .pub
ssh-keygen
#completamos lo que nos solicitan
#CREAMOS EL USUARIO GIT
sudo adduser git
su git
cd
mkdir .ssh
sudo cp ~/.ssh/id_rsa.pub /home/git
su git
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
exit
#LA PRIMERA VEZ
#Hacemos un repositorio local
cd ~
mkdir my_project
cd my_project
git init
cd ~
git clone --bare my_project my_project.git
#PONER EL REPOSITORIO EN EL SERVER
scp -r my_project.git ruben0909@192.168.1.130:/media/DATOS1
#permisos en el directorio a git
cd /media/DATOS1/my_project.git
#DAR PERMISOS A GIT SOLO PARA COSAS DE GIT
#Para una mayor protección, puedes restringir facilmente el usuario 'git' a realizar solamente actividades relacionadas con Git
which git-shell
#anotar resultado
sudo nano /etc/passwd
#En la linea parecida a
#git:x:1000:1000::/home/git:/bin/shgit:x:1000:1000::/home/git:/bin/sh
#sustituir /bin/sh por el resultado de "which git-shell"
#Ctrl + o , Ctrl +x
#SUCESIVAS VECES PARA CREAR UN NUEVO REPOSITORIO
cd /media/DATOS1/
mkdir project2.git
cd project2.git
git --bare init
#CLONAR REPOSITORIO(otro usuario)
git clone ruben0909@192.168.1.130:/media/DATOS1/my_project2.git
#Clonar repositorio SmartGit
git clone ssh://ruben0909@192.168.1.130:/media/DATOS1/my_project2.gitIn my case I have chosen the SSH protocol but you can use any other in addition, below I leave you a link to a tutorial in which it is explained


![[How to] Git Tutorial - Introduction, Installation and Configuration (Part 1)](/wp-content/uploads/2014/01/git_hu_368acdbe959d23d0.png)

