the gift of git [español: la palabra de git]
TRANSCRIPT
git?“Git is a free and open source distributed version control system designed to
handle everything from small to very large projects with speed and efficiency.”1
1 https://git-scm.com/
Que son los VCS?
Son sistemas que almacenan diferentes “versiones” de archivos a través del tiempo.
Estas versiones pueden diferir casi completamente o en sólo un carácter, da igual el tamaño del cambio.
El sistema puede o no dar acceso a dichas versiones para poder consultarlas después, además de dar una idea de la historia del proyecto.
Porqué git?
Git te permitirá manejar tu base de código de manera más rápida y limpia que FTP u otras soluciones de VCS.
Por favor notar que los ejemplos utilizados durante esta presentación se harán en código, pero que git puede manejar también imágenes, documentos u cualquier otro tipo de archivo (ej: Las versiones de presentación fueron manejadas en un repositorio git2).
2 https://github.com/felipecabargas/devcon-keynote
Porqué git?
SOURCE: http://nvie.com/posts/a-successful-git-branching-model/
Workflow básico: Inicio, Remotos y Clonado
~ $ mkdir source-code~ $ cd source-codesource-code $ git initInitialized empty Git repository in /Users/Felipe/source-code/.git/source-code $ git remote add origin [email protected]:felipecabargas/source-code.gitsource-code $
~ $ git clone [email protected]:felipecabargas/source-code.gitCloning into ‘source-code'...remote: Counting objects: 1, done.remote: Compressing objects: 100% (1/1), done.remote: Total 1 (delta 1), reused 0 (delta 0), pack-reused 1Receiving objects: 100% (1/1), 3.14 MiB | 1.83 MiB/s, done.Resolving deltas: 100% (1/1), done.Checking connectivity... done.~ $ cd source-codesource-code $
init & remotes clone
Workflow básico: Cambios y Sincronización
source-code $ vi README.mdsource-code $ ✗ git add README.mdsource-code $ git commit -m “Add: README file”Created commit 8b3b8b3: Add: README file1 files changed, 120 insertions(+), 0 deletions(-)source-code $ git push origin master
source-code $ git push REMOTE BRANCH
source-code $ git statusOn branch masternothing to commit, working directory cleansource-code $ git pullremote: Counting objects: 1, done.remote: Compressing objects: 100% (1/1), done.remote: Total 1 (delta 1), reused 0 (delta 1)Receiving objects: 100% (1/1), 1.78 KiB | 43.00 KiB/s, done.Resolving deltas: 100% (1/1), completed with 0 local objects.From git.example.com:code * branch master -> FETCH_HEAD 9018073..8b3b8b3 master -> origin/masterUpdating 9018073..8b3b8b3
add, commit & push status & pull
Git internals in real life
tag commit tree blob
tree blob
blobREADME.md
LICENSE.md
lib/
main.rb
01e4a5 e9a4fa
f5b345
e7b3b3
1674ac
d45b2a
Ciclo de vida de un archivo en git
Nuevo Archivo
no seguido
vi FILE
Añadido al diff
preparado para commit
git add FILE
1er Commit
no contiene modificaciones
git commit
Editado
nuevas modificaciones
vi FILE
Añadido al diff
no contiene modificaciones
git add FILE
2do Commit
no contiene modificaciones
git commit
se crea el BLOB o se referencia a uno
idéntico
se debieran pushear los cambios
Modelo de “ramas” https://gitlab.com/cabargas/git-ex/network/master
proy
ecto
Modelo de “ramas”
source-code $ git log —-oneline —-graph* 80be68a Update: schema* 31072d6 Fix: Refactor table to avoid reservated column name* 3f94aac Added pry* 235e78e Add: belongs_to account* 48d1c45 Add contribution guide* df7709e Add changelog* 6d3fb18 Add: act_as_nested_set rule to Account model* c1048c7 Update: schema* eff0920 Add: model Account* cd97c6c Update: schema* 5552c51 Add: account_id relationship for Users* 51b6fe3 Update: schema* a5a4611 Add: Devise User model* 28f2489 Add: Autogenerated Rails 4.2 app* c11e740 add README
Modelo de “ramas”: Creando Ramas
source-code (master) $ git branch world-featuresource-code (master) $ git checkout world-featuresource-code (world-feature) $··· MANY COMMITS ON THIS BRANCH··source-code (world-feature) $
branch & checkout
Modelo de “ramas”: Re-referenciando ramas
source-code (world-feature) $··· MANY COMMITS ON THIS BRANCH··source-code (world-feature) $ git checkout mastersource-code (master) $ git pull origin mastersource-code (master) $ git checkout world-featuresource-code (world-feature) $ git rebase masterFirst, rewinding head to replay your work on top of it...Applying: Add: world featureApplying: Add: es versionsource-code (world-feature) $ git push origin world-feature
rebase
Modelo de “ramas”: Mezclando ramas
source-code (world-feature) $ git push origin new-branchCounting objects: 6, done.Delta compression using up to 4 threads.Compressing objects: 100% (4/4), done.Writing objects: 100% (6/6), 590 bytes | 0 bytes/s, done.Total 6 (delta 0), reused 0 (delta 0)To [email protected]:cabargas/git-ex.gitsource-code (world-feature) $ git checkout mastersource-code (world-feature) $ git merge —-no-ff world-feature
merge
@juanpintoduran http://blog.nondrivendevelopment.com
SLIDES, REPOSITORIES & EXAMPLES: http://devcon.cabargas.me