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

La Palabra de Git [IV Devs revision]

La Palabra de Git [IV Devs revision]

Charla introductoria a los Sistemas de Control de Versiones (VCS) y a Git, a través de una serie de comandos explicados con ejemplos de uso y buenas prácticas.

A. Felipe Cabargas Madrid

October 24, 2015
Tweet

More Decks by A. Felipe Cabargas Madrid

Other Decks in Programming

Transcript

  1. vi

  2. 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.
  3. 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 Porque git?
  4. Git

  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. 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 status & pull Workflow básico: Cambios y Sincronización add, commit & push
  7. Nuevo Archivo OPTFHVJEP touch FILE Stagged QSFQBSBEPQBSBDPNNJU git add FILE

    1er Commit OPDPOUJFOFNPEJpDBDJPOFT git commit Editado OVFWBTNPEJpDBDJPOFT vi FILE Stagged OPDPOUJFOFNPEJpDBDJPOFT git add FILE 2do Commit OPDPOUJFOFNPEJpDBDJPOFT git commit TFDSFBFM#-0# PTFSFGFSFODJBBVOP JEÉOUJDP TFEFCJFSBOQVTIFBS MPTDBNCJPT File Life-cycle
  8. 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
  9. 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 Creando Ramas
  10. 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 Moviendo ramas
  11. 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 (master) $ git merge —-no- ff world-feature merge Mezclando ramas
  12. Q&A