Introducción a git y GitHub

  • Published on
    17-May-2015

  • View
    1.594

  • Download
    4

DESCRIPTION

Diapositivas de la charla dada por la gente de uno21.com.ar (@luke_ar y @matitanio) en la UP, el da 21/08/2012. Prximamente en otras universidades :)

Transcript

  • 1. git /t/@luke_ar#charlagit uno21.com.ar @matitanio

2. quesgit? 3. quesgit?unscv 4. unsistemadecontroldeversionesesnuestroDeLoreanpersonalquenospermitirviajarporla historiadeunarchivoy nosproveerfacilidadesparaeltrabajoenequipo 5. reporevision forkcommittree branchlabel head conflictupdate trunkcheckout tagcheckin workingcopy changelist merge 6. quesgit? 7. gitesunsistemadecontrol deversionesdistribudodecdigoabiertodiseadopara lavelocidadyeficiencia 8. gitesunsistemadecontrol deversionesdistribuidodecdigoabiertodiseadopara lavelocidadyeficiencia 9. totalmentedistribuido 10. (casi)todoeslocal 11. loquesignificaque todoesrpidocadarepositorioesunbackupsepuedetrabajaroffline 12. nosenecesitaredparahacerundiff verelhistrico commitearcambiosmergearbranchesobtenerunarevisindeunarchivo cambiardebranch 13. gitesunsistemadecontrol deversionesdistribudodecdigoabiertodiseadopara lavelocidadyeficiencia 14. gitscm.com 15. github.com/git/git 16. gitesunsistemadecontrol deversionesdistribuidodecdigoabiertodiseadoparalavelocidadyeficiencia 17. inmutable 18. (casi)nuncaseborrandatos 19. snapshots,noparches 20. (esolodejamosparadespus) 21. gitlocal 22. demo 23. primerospasos 24. gitconfig$ git config --global user.name "Lucas Videla"$ git config --global user.email"lucas@uno21.com.ar"$ git config --global color.ui true 25. gitinit$ git initInitialized empty Git repository in/home/lucas/workspace/demo-git/.git/ 26. gitstatus$ git status# On branch master## Initial commit## Untracked files:# (use "git add ..." to include in whatwill be committed)## README.mdnothing added to commit but untracked filespresent (use "git add" to track) 27. gitadd$ git add README.md$ git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached ..." tounstage)## new file: README.md# 28. gitstatus$ git status# On branch master# Initial commit# Changes to be committed:# (use "git rm --cached ..." to unstage)# new file:README.md## Changes not staged for commit:# (use "git add ..." to update what will becommitted)# (use "git checkout -- ..." to discardchanges in working directory)# modified:README.md## Untracked files:# (use "git add ..." to include in whatwill be committed)# index.html 29. gitadd$ git add .$ git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached ..." tounstage)## new file: README.md# new file: index.html# 30. gitcommit$ 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. gitstatus$ vim README.md$ git status# On branch master# Changes not staged for commit:# (use "git add ..." to update whatwill be committed)# (use "git checkout -- ..." to discardchanges in working directory)## modified: README.md# 32. gitcommit$ git commit -am "Cambios en el readme"[master 088d366] Cambios en el readme 1 file changed, 1 insertion(+), 1 deletion(-) 33. gitlog$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla Date: Wed Aug 15 14:21:40 2012 -0300Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla Date: Wed Aug 15 14:16:18 2012 -0300Commit inicial 34. gitlog$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla Date: Wed Aug 15 14:21:40 2012 -0300Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla Date: Wed Aug 15 14:16:18 2012 -0300Commit inicial 35. gitlog$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla Date: Wed Aug 15 14:21:40 2012 -0300Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla Date: Wed Aug 15 14:16:18 2012 -0300Commit inicial 36. gitlog$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla Date: Wed Aug 15 14:21:40 2012 -0300Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla Date: Wed Aug 15 14:16:18 2012 -0300Commit inicial 37. gitlog$ git logcommit 088d366628eeb349ee612123ca6267ca3f98ba2cAuthor: Lucas Videla Date: Wed Aug 15 14:21:40 2012 -0300Cambios en el readmecommit 0b8f623aa377049c1b9a41da5b8ea6de0722cb74Author: Lucas Videla Date: Wed Aug 15 14:16:18 2012 -0300Commit inicial 38. gitlol* $ git lol * 088d366 (HEAD, master) Cambios en el readme * 0b8f623 Commit inicial088d366 HEAD master0b8f623 39. gitbranch $ git branch * master $ git checkout -b fondoAzul Switched to a new branch fondoAzul $ git branch * fondoAzul master088d366 HEAD master fondoAzul0b8f623 40. gitadd $ vim index.html $ git commit -am "Se cambia el fondo a azul" [fondoAzul d20ddf9] Se cambia el fondo a azul1 file changed, 1 insertion(+), 1 deletion(-)d20ddf9 HEADfondoAzul088d366master0b8f623 41. gitcheckout $ git checkout master Switched to branch master $ vim index.html $ git commit -am "Se cambia la letra a ttulo" [master 45ba368] Se cambia la letra a ttulo1 file changed, 1 insertion(+), 1 deletion(-)d20ddf9fondoAzul 45ba368master HEAD088d3660b8f623 42. gitmerge $ git merge fondoAzul Auto-merging index.html Merge made by the recursive strategy.index.html |2 +-1 file changed, 1 insertion(+), 1 deletion(-)e9de90amasterHEADd20ddf9fondoAzul 45ba368088d3660b8f623 43. gittag $ git tag -a v0.0.1 -m "Primera versin del sitio" $ git tag V0.0.1e9de90amasterHEAD tag: v0.0.1d20ddf9fondoAzul 45ba368088d3660b8f623 44. gitbranchd $ git branch -d fondoAzul Deleted branch fondoAzul (was ce1c815).e9de90amaster HEAD tag: v0.0.1d20ddf9 45ba368088d3660b8f623 45. gitcheckout $ git checkout 088d366 index.html ?e9de90amaster HEAD tag: v0.0.1d20ddf9 45ba368088d3660b8f623 46. gitdiff$ git diff --cacheddiff --git a/index.html b/index.htmlindex 1007883..ae750ea 100644--- a/index.html+++ b/index.html@@ -1,7 +1,7 @@ -+ Bienvenido! 47. gitcommit $ git commit -am "Se restaura index" [master f2736c8] Se restaura index1 file changed, 1 insertion(+), 1 deletion(-)f2736c8master HEADe9de90atag: v0.0.1d20ddf9 45ba368088d3660b8f623 48. Breverepaso gitconfig gitinit gitadd gitcommit gitlog gitbranch gitcheckout gitdiff 49. Breverepaso gitconfig gitinit gitadd gitcommit gitlog gitbranch gitcheckout gitdiff 50. workflowgitbsico(a.k.a.cmotrabajarcongit) 51. directoriode trabajo indexrepositorio 52. directoriolacopiadetrabajode trabajodelproyecto index elestado intermedio,stagerepositorio basededatosconlahistoriadelproyecto 53. 1.editararchivos2.pasarastage3.revisarcambios4.hacercommit 54. directoriode trabajogitadd indexgitcommitrepositorio 55. gitremoto 56. demo2 57. http://github.com 58. gitremote$ git remote add origingit@github.com:delucas/demo-git.git$ git remoteorigin 59. gitpush$ 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. Momento!origin/masterf2736c8 master HEADe9de90a tag: v0.0.1d20ddf945ba368088d3660b8f623 61. gitclone$ 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. gitpull$ 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. Momento!origin/master5c565c5 master HEADf2736c8e9de90a tag: v0.0.1d20ddf945ba368088d3660b8f623 64. gitcommit$ git commit -am "Se establece fondo azul"[master aca1dbf] Se establece fondo azul 1 file changed, 1 insertion(+), 1 deletion(-) 65. Momento!aca1dbf master HEAD5c565c5 origin/masterf2736c8e9de90a tag: v0.0.1d20ddf945ba368088d3660b8f623 66. gitpush$ 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. gitpull$ 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 * branchmaster-> FETCH_HEADAuto-merging index.htmlCONFLICT (content): Merge conflict inindex.htmlAutomatic merge failed; fix conflicts and thencommit the result. 68. Momento! masteraca1dbf 27ac778HEAD 5c565c5 origin/master f2736c8 e9de90a tag: v0.0.1 d20ddf945ba368 088d366 0b8f623 69. gitdiff$ git diffdiff --cc index.htmlindex fba4d43,f5f9763..0000000--- a/index.html+++ b/index.html@@@ -1,7 -1,7 +1,11 @@@++>27ac778abf019e73d9bb3eb99b10cce0877b9108Welcome! 70. gitdiff$ git status# On branch master# Unmerged paths:# (use "git add/rm ..." 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. Momento! masterHEADe3be094aca1dbf27ac7785c565c5 origin/masterf2736c8e9de90a tag: v0.0.1d20ddf945ba368088d3660b8f623 72. gitpush$ 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. Momento!origin/mastere3be094 master HEAD aca1dbf 27ac7785c565c5f2736c8e9de90a tag: v0.0.1d20ddf945ba368088d3660b8f623 74. entendiendogit 75. snapshots,noparchesgracias,Scott!(@chacon) 76. elmodelodeobjetos 77. elmodelodeobjetos 78. elobjetocommit 79. elobjetocommit 80. elobjetocommit 81. losbranches 82. (esunpunteroauncommit) 83. HEAD 84. gitbranchexperiment 85. gitcheckoutexperiment 86. gitcommit 87. gitcommit 88. gitcheckoutdefault 89. gitcommit 90. gitcheckoutexperimentgitcommit 91. merge 92. gitcheckoutdefault 93. gitmergeexperiment 94. (pausa) 95. preguntas? 96. recursosgit 97. gitscm.com 98. help.github.com 99. gitimmersion.com 100. gitcasts.com 101. codeschool.com/courses/trygit 102. nvie.com/posts/asuccessfulgitbranchingmodel/ 103. muchasgracias!@luke_ar#charlagit@matitanio