domingo, 17 de enero de 2016

Instalar git

$sudo apt-get install git
$sudo apt-get install git-core
$sudo apt-get install git-arch git-cvs git-svn git-email git-daemon-run git-gui gitk gitweb cogito git-doc curl

A continuacion configuramos el CVS-Git

$git config --global user.name "David Vielba Garcia"
$git config --global user.email "dvielba@blom.es"
$git config --global color.diff auto
$git config --global color.status auto
$git config --global color.branch auto

Uso de Git
$git init
Initialized empty Git repository in .git/

$ls -l .git
total 32
drwxr-xr-x 2 jcgutierrez jcgutierrez 4096 2008-05-14 11:38 branches
-rw-r--r-- 1 jcgutierrez jcgutierrez 92 2008-05-14 11:38 config
-rw-r--r-- 1 jcgutierrez jcgutierrez 58 2008-05-14 11:38 description
-rw-r--r-- 1 jcgutierrez jcgutierrez 23 2008-05-14 11:38 HEAD
drwxr-xr-x 2 jcgutierrez jcgutierrez 4096 2008-05-14 11:38 hooks
drwxr-xr-x 2 jcgutierrez jcgutierrez 4096 2008-05-14 11:38 info
drwxr-xr-x 4 jcgutierrez jcgutierrez 4096 2008-05-14 11:38 objects
drwxr-xr-x 4 jcgutierrez jcgutierrez 4096 2008-05-14 11:38 refs

$cd intranet
$git init
Initialized empty Git repository in .git

$git add .

$git commit - nos aparece todo un listado de los ficheros que queremos guardar en el commit

Cuando se hace algun cambio en un fichero, hay que realizar los siguientes pasos:

$git add index.php

$git commit
Cuando hacemos esto aparece un fichero con todos los cambios posibles, pero vienen comentados. Hay que quitar la almohadilla, guardar el documento, y se hace el commit.

Para poder cambiar las almohadillas(cuando hay muchas) podemos utilizar la siguiente instruccion:

:170,$ s/^#/ /
Esto quiere decir, desde la linea 170 hasta el final , sustituimos el primer caracter almohadilla por un espacio en blanco. El ultimo slash quire decir que solo se haga una vez

Created commit 103d0bb: modified: index.php
1 files changed, 1 insertions(+), 1 deletions(-)

Para borrar un objeto del repositorio

$git rm index.php

$git commit
Para salvar los cambios. Se puede hacer git commit -a y te hace a la vez el proceso de añadir ficheros y el commit

Para saber si tenemos algo pendiente de guardar, lo podemos ver de la siguente manera:
$git status
#On branch intranet
#Changed but not updated:
#(use "git add/rm ..." to update what will be committed)
#
# deleted: dad.php
#
no changes added to commit (use "git add" and/or "git commit -a")

Branch - ramas.
Esto tiene sentido cuando el proyecto puede tomar varios caminos en el desarrollo. De esta forma se sigue teniendo un repositorio(tendriamos una rama principal y luego las diferentes ramas que hiciesen falta)
$git branch
intranet
 master

 origin/master

 v1.1.1


Para poder cambiarse entre ramas utilizamos
$git checkout master
Nos vamos al branch master(lo identifica por el asterisco).

Acceso remoto

Para que una maquina, tenga acesso a este repositorio hay que instalar los paquetes git y git-core
$apt-get install git git-core

Una vez hecho esto, para clonar un repositorio externo hacemos lo siguiente
$git clone jcgutierrez@192.168.33.234:/home/jcgutierrez/intranet /home/david/intranet
Initialized empty Git repository in /home/david/intranet/.git/
The authenticity of host '192.168.33.234 (192.168.33.234)' can't be established.
RSA key fingerprint is fc:c9:84:26:73:99:ae:44:14:33:14:5f:8f:f8:13:43.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.33.234' (RSA) to the list of known hosts.
jcgutierrez@192.168.33.234's password:
remote: Generating pack...
remote: Done counting 1765 objects.
remote: Deltifying 1765 objects...
remote: 100% (1765/1765) done
Indexing 1765 objects...
remote: Total 1765 (delta 902), reused 0 (delta 0)
100% (1765/1765) done
Resolving 902 deltas...
100% (902/902) done

Hay que tener en cuenta que solo clonamos la rama(branch) en la que esta la maquina original. En este caso estamos en la rama branch intranet
$git branchintranet

Para subir al repositorio, se hace de la siguiente forma:
$git push jcgutierrez@192.168.33.234:/home/jcgutierrez/intranet
The authenticity of host '192.168.33.234 (192.168.33.234)' can't be established.
RSA key fingerprint is fc:c9:84:26:73:99:ae:44:14:33:14:5f:8f:f8:13:43.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.33.234' (RSA) to the list of known hosts.
jcgutierrez@192.168.33.234's password:
updating 'refs/heads/intranet'
from b721e22921c4b52f59e6dc8d9443ac53eed52a06
to 21a18e0da5cab3354bbd7daa6167a6ee504d4d6f
Generating pack...
Done counting 3 objects.
Result has 2 objects.
Deltifying 2 objects...
100% (2/2) done

Writing 2 objects...
100% (2/2) done

Total 2 (delta 1), reused 0 (delta 0)
refs/heads/intranet: b721e22921c4b52f59e6dc8d9443ac53eed52a06 -> 21a18e0da5cab3354bbd7daa6167a6ee504d4d6f

Con git pull se guarda el repositorio solo los cambios

$sudo git pull
jcgutierrez@192.168.33.234's password:
jcgutierrez@192.168.33.234's password:
refs/remotes/origin/intranet: fast forward to branch 'intranet' of jcgutierrez@192.168.33.234:/home/jcgutierrez/intranet
old..new: b721e22..21a18e0
Already up-to-date.
Instalación Git 
#El paquete git-daemon-run que usa los daemon tools de djb está roto en Ubuntu, ya que intenta escribir a /etc/inittab que no existe. 
#Lo falsificamos y luego lo reparamos. sudo touch /etc/inittabsudo apt-get remove git-daemon-run git-core 
sudo cat /etc/event.d/git-daemon < EOF ____________________________________________ 
# git-daemon startup taken from /etc/initab 
# Debian doesn't use inittab but the .deb git-daemon tries to install it anyway 
# so I've moved the call to /etc/event.d/git-daemon 
# mrp, 17/12/2007 start on runlevel-3 start on runlevel-4 start on runlevel-5 stop on shutdown 
#-- runit begin #SV:123456:respawn:/usr/sbin/runsvdir-start exec /usr/sbin/runsvdir-startrespawn 
#-- runit end ___________________________________________________ EOF 
sudo mv /etc/inittab /etc/inttab.git.daemon 
# Lanzamos el demonio sudo start git-daemonsudo apt-get install git-gui gitweb apache2 rsync sudo cat /etc/rsyncd.conf < EOF ________________________________________________ 
#motd file=/etc/motd 
#log file=/var/log/rsyncd 
# for pid file, do not use /var/run/rsync.pid if 
# you are going to run rsync out of the init.d script. pid file=/var/run/rsyncd.pid #syslog facility=daemon 
#socket options= 
# MODULE OPTIONS [ftp]

       comment = public archive
       path = /var/www/pub
       use chroot = yes
# max connections=10
       lock file = /var/lock/rsyncd 
# the default for read only is yes...
       read only = yes
       list = yes
       uid = nobody
       gid = nogroup
# exclude = # exclude from = # include = # include from = # auth users = # secrets file = /etc/rsyncd.secrets
       strict modes = yes
# hosts allow = # hosts deny =
       ignore errors = no
       ignore nonreadable = yes
       transfer logging = no 
# log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
       timeout = 600
       refuse options = checksum dry-run
       dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz # Version control sync 
# mrp, 19/12/2007 [git]
   path = /var/cache/git
   readonly = yes
_______________________________________________ EOF sudo cat /etc/apache2/sites-available/git.mad.blom.lan < EOF ___________________________________________________________
   ServerName git.mad.blom.lan
   ServerAdmin webmaster@blom.es
   HeaderName HEADER
    # bogus but safe DocumentRoot
   DocumentRoot /var/cache/git
   ErrorLog /var/log/apache2/gitmad.blom.lan-error.log
   CustomLog /var/log/apache2/gitmad.blom.lan-access.log combined
   Alias /robots.txt /var/www/cvs.robots.txt
    Alias /gitweb.css /var/www/gitweb.css
   Alias /git /var/cache/git
   ScriptAlias / /usr/lib/cgi-bin/gitweb.cgi
   RedirectMatch permanent "^/~(.*)$" "http://mad.blom.lan/~$1 "
____________________________________________________________ EOF 
sudo /etc/init.d/apache2 reload 
sudo /etc/init.d/rsync restart 
# Miramos los daños que hemos hecho sudo netstat -tanp 
sudo sv stat git-daemon 
sudo cat /var/log/git-daemon/current 
# Git tiene los repositorios todavia vacios así que creamos un proyecto rápidamente 
# Sigo usando el usuario "makis"... los ficheros son mios, 
cd mkdir src 
cd src 
tar mapserver-5.0.0.tar.gz 
cd mapserver-5.0.0 
make clean 
git config --global user.name "jc" 
git config --global user.email "jc@pp.es" 
git init git add
git commit 
# Quitar los comentarios 
# 11,$ s/^
#// 
# wq ls -lR .git/git log 
# Ahora conectamos nuestro proyecto con el servidor de git(). 
sudo ln -s /home/makis/src/mapserver- 5.0.0/.git /var/cache/git/mapserver.git 
# Existen 136 ejecutables git-* y vuestro favorito será (todavía dentro de mapserver-5.0.0 git.gui 
ile:/usr/share/doc/git-core/README.Debian 

No hay comentarios:

Publicar un comentario

Nota: solo los miembros de este blog pueden publicar comentarios.