Introducció al Git
-
Upload
ymbra -
Category
Technology
-
view
1.407 -
download
1
description
Transcript of Introducció al Git
![Page 1: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/1.jpg)
Introducció a GitRamon Vilar Gavaldà
![Page 2: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/2.jpg)
2
QUI SÓC
Ramon Vilar Gavaldà
http://ymbra.com/blogs/ramon
http://twitter.com/rvilar
http://drupal.org/user/293298
● Soci fundador d'Ymbra● Desenvolupador Drupal● Desenvolupador frontend● Membre actiu de la
comunitat drupalera:● President de Drupal.cat● Administrador de la traducció
catalana del Drupal
![Page 3: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/3.jpg)
Ymbra Drupal dreamers 3
ÍNDEX
01. QUÈ ÉS GIT?
02. CENTRALITZATS VS. DISTRIBUÏTS
03. CARACTERÍSTIQUES
04. ELS TRES ESTATS DE GIT
05. CONFIGURACIÓ BÀSICA
06. FLUX DIARI DE TREBALL
07. COMANDES ÚTILS
08. BRANQUES
09. REMOTS
![Page 4: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/4.jpg)
Ymbra Drupal dreamers 4
QUÈ ÉS GIT?
● Git és un sistema de control de versions distribuït
● Va néixer de les mans de Linus Torvalds● Es va concebre per poder mantenir el nucli de
Linux després de trencar al 2005 amb BitKeeper
![Page 5: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/5.jpg)
Ymbra Drupal dreamers 5
CENTRALITZATS VS. DISTRIBUÏTS (I)
● SCV centralitzats● Un “únic” repositori● Una única línia de treball
![Page 6: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/6.jpg)
Ymbra Drupal dreamers 6
CENTRALITZATS VS. DISTRIBUÏTS (I II)
● SCV distribuïts● Cada usuari té com a mínim un repositori complet
![Page 7: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/7.jpg)
Ymbra Drupal dreamers 7
CARACTERÍSTIQUES (I)
● Les característiques principals amb les que es va plantejar el Git són:● Velocitat● Disseny simple● Gran suport per al desenvolupament no
lineal (amb suport per a milers de branques)● Completament distribuït● Capacitat per a gestionar grans projectes
![Page 8: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/8.jpg)
Ymbra Drupal dreamers 8
CARACTERÍSTIQUES (I II)
● Algunes de les característiques intrínseques al Git són:● Git desa captures, no pas diferències● Quasi bé totes les operacions es fan en local● Git assegura la integritat● Git només afegeix dades (de forma general)
![Page 9: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/9.jpg)
Ymbra Drupal dreamers 9
ELS TRES ESTATS DEL GIT
● El flux de treball bàsic amb Git és el següent:
● Feu canvis als vostres fitxers al directori de treball.
● Afegiu canvis al staging area.
● Feu un commit, el qual agafa els fitxers tal i com estan a la staging area, i emmagatzema aquestes instantànies al directori del Git.
![Page 10: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/10.jpg)
Ymbra Drupal dreamers 10
CONFIGURACIÓ BÀSICA
● Abans de començar, cal identificar-nos-hi:git config --global user.name “Ramon Vilar”git config --global user.email “[email protected]”
● Es recomanable donar-li una mica de color a tot plegat:git config --global color.status autogit config --global color.branch autogit config --global color.diff auto
● Si volem veure què tenim:git config --list
![Page 11: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/11.jpg)
Ymbra Drupal dreamers 11
FLUX DIARI DE TREBALL
● Crear un repositorigit init gittest
● Veure l'estat del repositorigit status
● Afegir canvis al staging areagit add <nom_fitxer 1> ... <nom_fitxer n>
● Afegir canvis al repositorigit commit
![Page 12: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/12.jpg)
Ymbra Drupal dreamers 12
COMANDES ÚTILS
● “Eliminar” fitxers del repositorigit rm <nom_fitxer>
● Consultar històric de canvisgit log
● Eliminar els canvis fets al directori de treball
git checkout -- <nom_fitxer>git checkout .
● Afegir una etiquetagit tag <nom_etiqueta>
![Page 13: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/13.jpg)
Ymbra Drupal dreamers 13
BRANQUES
● Serveixen per organitzar diverses versions del codi
● Per crear una brancagit branch <nom_branca>
● Per canviar de brancagit checkout <nom_branca>
● Per unir/fondre dues branquesgit merge <nom_branca>
![Page 14: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/14.jpg)
Ymbra Drupal dreamers 14
REMOTS
● Els repositoris remots són versions del nostre repositori que estan a la xarxa
● Descarregar-nos el codi d'un remot (només un cop)● git clone http://git.drupal.org/project/drupal.git
● Pujar canvisgit push
● Actualitzar amb els canvis fets (descarregar)git pull
● Proves: https://github.com/octocat/Spoon-Knife
![Page 15: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/15.jpg)
Ymbra Drupal dreamers 15
RECURSOS
● Pro Git, Scott Chacon amb versió en línia http://progit.org/book
● Llibre en línia de la comunitat http://book.git-scm.com
● Bon model d'organització de branques http://ves.cat/a9ce
● Pàgina oficial de Git http://git-scm.com
● Bona referència per introducció a Git http://ves.cat/a9cg
![Page 16: Introducció al Git](https://reader033.fdocuments.co/reader033/viewer/2022052601/558e68f61a28abf4658b456a/html5/thumbnails/16.jpg)
16
CONTACTEU
● Twitter: @rvilar● Correu: [email protected]● Blog: http://ymbra.com/blogs/ramon● Web: http://ymbra.com
Gràcies a tots(es), preguntes?