Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Gift of Git [ES]

The Gift of Git [ES]

An introductory talk to VCS. Learn the basics of git through a series of actual every-day usage & how-to use it to make your workflow more efficient.

A. Felipe Cabargas Madrid

September 04, 2015
Tweet

More Decks by A. Felipe Cabargas Madrid

Other Decks in Programming

Transcript

  1. La palabra de git O cómo usar el control de

    versiones para trabajar feliz. DevCon Chile 2015
  2. 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/
  3. 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.
  4. 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
  5. Workflow básico: Inicio, Remotos y Clonado ~ $ mkdir source-code

    ~ $ cd source-code source-code $ git init Initialized empty Git repository in /Users/Felipe/ source-code/.git/ source-code $ git remote add origin [email protected]:felipecabargas/source-code.git source-code $ ~ $ git clone [email protected]:felipecabargas/ source-code.git Cloning 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 1 Receiving objects: 100% (1/1), 3.14 MiB | 1.83 MiB/s, done. Resolving deltas: 100% (1/1), done. Checking connectivity... done. ~ $ cd source-code source-code $ init & remotes clone
  6. Workflow básico: Cambios y Sincronización source-code $ vi README.md source-code

    $ ✗ git add README.md source-code $ git commit -m “Add: README file” Created commit 8b3b8b3: Add: README file 1 files changed, 120 insertions(+), 0 deletions(-) source-code $ git push origin master source-code $ git push REMOTE BRANCH source-code $ git status On branch master nothing to commit, working directory clean source-code $ git pull remote: 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/master Updating 9018073..8b3b8b3 add, commit & push status & pull
  7. Git internals in real life tag commit tree blob tree

    blob blob README.md LICENSE.md lib/ main.rb 01e4a5 e9a4fa f5b345 e7b3b3 1674ac d45b2a
  8. Ciclo de vida de un archivo en git Nuevo Archivo

    OPTFHVJEP vi FILE Añadido al diff QSFQBSBEPQBSBDPNNJU git add FILE 1er Commit OPDPOUJFOFNPEJpDBDJPOFT git commit Editado OVFWBTNPEJpDBDJPOFT vi FILE Añadido al diff OPDPOUJFOFNPEJpDBDJPOFT git add FILE 2do Commit OPDPOUJFOFNPEJpDBDJPOFT git commit TFDSFBFM#-0# PTFSFGFSFODJBBVOP JEÉOUJDP TFEFCJFSBOQVTIFBS MPTDBNCJPT
  9. 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
  10. Modelo de “ramas”: Creando Ramas source-code (master) $ git branch

    world-feature source-code (master) $ git checkout world- feature source-code (world-feature) $ · · · MANY COMMITS ON THIS BRANCH · · source-code (world-feature) $ branch & checkout
  11. Modelo de “ramas”: Re-referenciando ramas source-code (world-feature) $ · ·

    · MANY COMMITS ON THIS BRANCH · · source-code (world-feature) $ git checkout master source-code (master) $ git pull origin master source-code (master) $ git checkout world- feature source-code (world-feature) $ git rebase master First, rewinding head to replay your work on top of it... Applying: Add: world feature Applying: Add: es version source-code (world-feature) $ git push origin world-feature rebase
  12. Modelo de “ramas”: Mezclando ramas source-code (world-feature) $ git push

    origin new-branch Counting 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.git source-code (world-feature) $ git checkout master source-code (world-feature) $ git merge —-no-ff world-feature merge
  13. Q&A