Introducción a git y GitHub

1,833 views
1,719 views

Published on

Diapositivas de la charla dada por la gente de uno21.com.ar (@luke_ar y @matitanio) en la UP, el día 21/08/2012. Próximamente en otras universidades :)

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,833
On SlideShare
0
From Embeds
0
Number of Embeds
524
Actions
Shares
0
Downloads
29
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Introducción a git y GitHub

  1. 1. git /ɡɪt/ @luke_ar#charlagit uno21.com.ar @matitanio
  2. 2. ¿qué es git?
  3. 3. ¿qué es git? un scv
  4. 4. un sistema de control de versiones es nuestro  DeLorean personal quenos permitirá viajar por la historia de un archivo y nos proveerá facilidadespara el trabajo en equipo
  5. 5. repo revision fork commit tree branchlabel head conflict update trunk check­out tagcheck­in working copy change list merge
  6. 6. ¿qué es git?
  7. 7. git es un sistema de control de versiones distribuído decódigo abierto diseñado para la velocidad y eficiencia
  8. 8. git es un sistema de control de versiones distribuido decódigo abierto diseñado para la velocidad y eficiencia
  9. 9. totalmente distribuido
  10. 10. (casi) todo es local
  11. 11. lo que significa que todo es rápidocada repositorio es un backup se puede trabajar off­line
  12. 12. no se necesita red para hacer un diff ver el histórico commitear cambios mergear branchesobtener una revisión de un archivo cambiar de branch
  13. 13. git es un sistema de control de versiones distribuído decódigo abierto diseñado para la velocidad y eficiencia
  14. 14. git­scm.com
  15. 15. github.com/git/git
  16. 16. git es un sistema de control de versiones distribuido decódigo abierto diseñado para la velocidad y eficiencia
  17. 17. inmutable
  18. 18. (casi) nunca se borran datos
  19. 19. snapshots, no parches
  20. 20. (eso lo dejamos para después)
  21. 21. git local
  22. 22. demo  ㋡
  23. 23. primeros pasos
  24. 24. git config$ git config --global user.name "Lucas Videla"$ git config --global user.email"lucas@uno21.com.ar"$ git config --global color.ui true
  25. 25. git init$ git initInitialized empty Git repository in/home/lucas/workspace/demo-git/.git/
  26. 26. git status$ git status# On branch master## Initial commit## Untracked files:# (use "git add <file>..." to include in whatwill be committed)## README.mdnothing added to commit but untracked filespresent (use "git add" to track)
  27. 27. git add$ git add README.md$ git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached <file>..." tounstage)## new file: README.md#
  28. 28. git status$ git status# On branch master# Initial commit# Changes to be committed:# (use "git rm --cached <file>..." to unstage)# new file: README.md## Changes not staged for commit:# (use "git add <file>..." to update what will becommitted)# (use "git checkout -- <file>..." to discardchanges in working directory)# modified: README.md## Untracked files:# (use "git add <file>..." to include in whatwill be committed)# index.html
  29. 29. git add$ git add .$ git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached <file>..." tounstage)## new file: README.md# new file: index.html#
  30. 30. git commit$ git commit -m "Commit inicial"[master (root-commit) 0b8f623] Commit inicial 2 files changed, 4 insertions(+) create mode 100644 README.md create mode 100644 index.html$ git status# On branch masternothing to commit (working directory clean)
  31. 31. git status$ vim README.md$ git status# On branch master# Changes not staged for commit:# (use "git add <file>..." to update whatwill be committed)# (use "git checkout -- <file>..." to discardchanges in working directory)## modified: README.md#
  32. 32. git commit$ git commit -am "Cambios en el readme"[master 088d366] Cambios en el readme 1 file changed, 1 insertion(+), 1 deletion(-)
  33. 33. git log$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:21:40 2012 -0300 Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:16:18 2012 -0300 Commit inicial
  34. 34. git log$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:21:40 2012 -0300 Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:16:18 2012 -0300 Commit inicial
  35. 35. git log$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:21:40 2012 -0300 Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:16:18 2012 -0300 Commit inicial
  36. 36. git log$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:21:40 2012 -0300 Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:16:18 2012 -0300 Commit inicial
  37. 37. git log$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:21:40 2012 -0300 Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla <lucas@uno21.com.ar>Date: Wed Aug 15 14:16:18 2012 -0300 Commit inicial
  38. 38. git lol* $ git lol * 088d366 (HEAD, master) Cambios en el readme * 0b8f623 Commit inicial088d366 HEAD master0b8f623
  39. 39. git branch $ git branch * master $ git checkout -b fondoAzul Switched to a new branch fondoAzul $ git branch * fondoAzul master088d366 HEAD master fondoAzul0b8f623
  40. 40. git add $ vim index.html $ git commit -am "Se cambia el fondo a azul" [fondoAzul d20ddf9] Se cambia el fondo a azul 1 file changed, 1 insertion(+), 1 deletion(-)d20ddf9 HEAD fondoAzul088d366 master0b8f623
  41. 41. git checkout $ git checkout master Switched to branch master $ vim index.html $ git commit -am "Se cambia la letra a título" [master 45ba368] Se cambia la letra a título 1 file changed, 1 insertion(+), 1 deletion(-)d20ddf9 fondoAzul 45ba368 master HEAD088d3660b8f623
  42. 42. git merge $ git merge fondoAzul Auto-merging index.html Merge made by the recursive strategy. index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)e9de90a master HEADd20ddf9 fondoAzul 45ba368088d3660b8f623
  43. 43. git tag $ git tag -a v0.0.1 -m "Primera versión del sitio" $ git tag V0.0.1e9de90a master HEAD tag: v0.0.1d20ddf9 fondoAzul 45ba368088d3660b8f623
  44. 44. git branch ­d $ git branch -d fondoAzul Deleted branch fondoAzul (was ce1c815).e9de90a master HEAD tag: v0.0.1d20ddf9 45ba368088d3660b8f623
  45. 45. git checkout $ git checkout 088d366 index.html ?e9de90a master HEAD tag: v0.0.1d20ddf9 45ba368088d3660b8f623
  46. 46. git diff$ git diff --cacheddiff --git a/index.html b/index.htmlindex 1007883..ae750ea 100644--- a/index.html+++ b/index.html@@ -1,7 +1,7 @@ <html> <head> </head>-<body style="background-color: blue;">+<body> <h1>Bienvenido!</h1>
  47. 47. git commit $ git commit -am "Se restaura index" [master f2736c8] Se restaura index 1 file changed, 1 insertion(+), 1 deletion(-)f2736c8 master HEADe9de90a tag: v0.0.1d20ddf9 45ba368088d3660b8f623
  48. 48. Breve repaso git config git init git add git commit git log git branch git checkout git diff
  49. 49. Breve repaso git config git init git add git commit git log git branch git checkout git diff
  50. 50. workflow git básico(a.k.a. “cómo trabajar con git”)
  51. 51. directoriode trabajo indexrepositorio
  52. 52. directorio la copia de trabajo de trabajo del proyecto index el estado  intermedio, stagerepositorio base de datos con la  historia del proyecto
  53. 53. 1. editar archivos2. pasar a stage3. revisar cambios4. hacer commit
  54. 54. directoriode trabajo git add index git commitrepositorio
  55. 55. git remoto
  56. 56. demo 2  ㋡
  57. 57. http://github.com
  58. 58. git remote$ git remote add origingit@github.com:delucas/demo-git.git$ git remoteorigin
  59. 59. git push$ git push origin masterCounting objects: 17, done.Delta compression using up to 4 threads.Compressing objects: 100% (15/15), done.Writing objects: 100% (17/17), 1.66 KiB, done.Total 17 (delta 2), reused 0 (delta 0)To git@github.com:delucas/demo-git.git * [new branch] master -> master
  60. 60. ¡Momento! origin/master f2736c8 master HEAD e9de90a tag: v0.0.1 d20ddf9 45ba368 088d366 0b8f623
  61. 61. git clone$ git clone git@github.com:delucas/demo-git.gitCloning into demo-git...remote: Counting objects: 17, done.remote: Compressing objects: 100% (13/13),done.remote: Total 17 (delta 2), reused 17 (delta 2)Receiving objects: 100% (17/17), done.Resolving deltas: 100% (2/2), done.
  62. 62. git pull$ git pull origin masterremote: Counting objects: 5, done.remote: Compressing objects: 100% (3/3), done.remote: Total 3 (delta 0), reused 3 (delta 0)Unpacking objects: 100% (3/3), done.From github.com:delucas/demo-git * branch master -> FETCH_HEADUpdating f2736c8..5c565c5Fast-forward index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
  63. 63. ¡Momento! origin/master 5c565c5 master HEAD f2736c8 e9de90a tag: v0.0.1 d20ddf9 45ba368 088d366 0b8f623
  64. 64. git commit$ git commit -am "Se establece fondo azul"[master aca1dbf] Se establece fondo azul 1 file changed, 1 insertion(+), 1 deletion(-)
  65. 65. ¡Momento! aca1dbf master HEAD 5c565c5 origin/master f2736c8 e9de90a tag: v0.0.1 d20ddf9 45ba368 088d366 0b8f623
  66. 66. git push$ git push origin masterTo git@github.com:delucas/demo-git.git ! [rejected] master -> master (non-fast-forward)error: failed to push some refs togit@github.com:delucas/demo-git.gitTo prevent you from losing history, non-fast-forward updates were rejectedMerge the remote changes (e.g. git pull)before pushing again. See theNote about fast-forwards section of git push--help for details.
  67. 67. git pull$ git pull origin masterremote: Counting objects: 8, done.remote: Compressing objects: 100% (6/6), done.remote: Total 6 (delta 0), reused 6 (delta 0)Unpacking objects: 100% (6/6), done.From github.com:delucas/demo-git * branch master -> FETCH_HEADAuto-merging index.htmlCONFLICT (content): Merge conflict inindex.htmlAutomatic merge failed; fix conflicts and thencommit the result.
  68. 68. ¡Momento! master aca1dbf 27ac778 HEAD 5c565c5 origin/master f2736c8 e9de90a tag: v0.0.1 d20ddf9 45ba368 088d366 0b8f623
  69. 69. git diff$ git diffdiff --cc index.htmlindex fba4d43,f5f9763..0000000--- a/index.html+++ b/index.html@@@ -1,7 -1,7 +1,11 @@@ <html> <head> </head>++<<<<<<< HEAD +<body style="background-color:blue;">++=======+ <body style="background-color:red;">++>>>>>>>27ac778abf019e73d9bb3eb99b10cce0877b9108 <h1>Welcome!</h1>
  70. 70. git diff$ git status# On branch master# Unmerged paths:# (use "git add/rm <file>..." as appropriateto mark resolution)## both modified: index.htmlno changes added to commit (use "git add"and/or "git commit -a")$ git diffdiff --cc index.htmlindex fba4d43,f5f9763..0000000--- a/index.html+++ b/index.html$ git commit -am "Se resuelve conflicto demerge"[master e3be094] Se resuelve conflicto de merge
  71. 71. ¡Momento! master HEAD e3be094 aca1dbf 27ac778 5c565c5 origin/master f2736c8 e9de90a tag: v0.0.1 d20ddf9 45ba368 088d366 0b8f623
  72. 72. git push$ git push origin masterCounting objects: 8, done.Delta compression using up to 4 threads.Compressing objects: 100% (4/4), done.Writing objects: 100% (4/4), 503 bytes, done.Total 4 (delta 1), reused 0 (delta 0)To git@github.com:delucas/demo-git.git 27ac778..e3be094 master -> master
  73. 73. ¡Momento! origin/master e3be094 master HEAD aca1dbf 27ac778 5c565c5 f2736c8 e9de90a tag: v0.0.1 d20ddf9 45ba368 088d366 0b8f623
  74. 74. entendiendo git
  75. 75. snapshots, no parches gracias, Scott! (@chacon)
  76. 76. el modelo de objetos
  77. 77. el modelo de objetos
  78. 78. el objeto commit
  79. 79. el objeto commit
  80. 80. el objeto commit
  81. 81. los branches
  82. 82. (es un puntero a un commit)
  83. 83. HEAD
  84. 84. git branch experiment
  85. 85. git checkout experiment
  86. 86. git commit
  87. 87. git commit
  88. 88. git checkout default
  89. 89. git commit
  90. 90. git checkout experimentgit commit
  91. 91. merge
  92. 92. git checkout default
  93. 93. git merge experiment
  94. 94. (pausa)
  95. 95. ¿preguntas?
  96. 96. recursos git
  97. 97. git­scm.com
  98. 98. help.github.com
  99. 99. gitimmersion.com
  100. 100. gitcasts.com
  101. 101. codeschool.com/courses/try­git
  102. 102. nvie.com/posts/a­successful­git­branching­model/
  103. 103. ¡muchas gracias! @luke_ar#charlagit @matitanio

×