Sacándole jugo a git
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Sacándole jugo a git

  • 231 views
Uploaded on

Introducción a git, algo sobre github y comandos avanzados.

Introducción a git, algo sobre github y comandos avanzados.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
231
On Slideshare
229
From Embeds
2
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 2

https://twitter.com 2

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. jugo a GIT Sacándole ocalipsis ervivencia para el ap Manual de sup // Porque con zombies todo suena más molón zombie
  • 2. uién soy yo? ¿Q Berny Cantos Developeando since 1994 Usando GIT desde 2011 Currando en Ofertix™ desde 2013 @xPheRe
  • 3. ¿Qué es GIT?
  • 4. es un DVCS GIT ● ● ● ● Distributed Version Control System
  • 5. S? (sin la D) ¿Qué es un VC ● Gestión de cambios ¿Qué? ¿Cuándo? ¿Cómo? ¿Por qué?
  • 6. S? (sin la D) ¿Qué es un VC ● Gestión de cambios ¿Quién?
  • 7. S? (sin la D) ¿Qué es un VC ● Máquina del tiempo
  • 8. S? (sin la D) ¿Qué es un VC ● DISCLAIMER: un VCS no es esto
  • 9. S? (sin la D) ¿Qué es un VC ● Colaboración
  • 10. ¿Y la D? ● Cambios distribuidos ● Trabajar en repositorio local ● Compartir en repositorio remoto
  • 11. funciona GIT? ¿Cómo
  • 12. e a tus aliados Conoc ● ● ● ● Working Tree / Workspace Index / Staging area Local repository Remote repository
  • 13. s de un fichero Index: Estado rm Indexed Modified Untracked Unmodified add add (--patch) commit
  • 14. push commit -a Remote commit Local add Index Working Tree dos escritura Coman
  • 15. checkout reset --hard fetch Remote reset Local Index Working Tree mandos lectura Co pull
  • 16. mo funciona? ¿Có * Blob * Tree Commit Tag Ref
  • 17. Referencias ● Punteros a un commit ● Ligeros de gestionar ● Diversos tipos ○ ○ ○ ○ tag branch remote symbolic
  • 18. Workflow ● Ventaja ○ git no define un workflow ● Inconveniente ○ git no define un workflow
  • 19. adir un título z ando par s añ mclick s báaicos Ho Ca
  • 20. Inicialización > git init "." Initialized empty Git repository in /home/jrrt/docs/.git
  • 21. Configuración > git config user.email "root@middle-earth.com" > git config user.name "John Ronald Reuel Tolkien" --global > git config core.editor "vi" --system
  • 22. stá pasando? ¿Qué e > git status # # # # # # # # # On branch master Untracked files: (use "git add <file>..." to include in what will be committed) the-hobbit.txt nothing added to commit but untracked files present use "git add" to track
  • 23. stá pasando? ¿Qué e > git status --short --branch --untracked-files=normal ## Initial commit on 'master' branch ?? the-hobbit.txt
  • 24. primer commit Mi > git add -A > git commit > git commit -a -m "Not a dwarf's story" --edit [master (root-commit) 7b092a2] Not a dwarf's story 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 the-hobbit.txt HEAD master  7b09 
  • 25. de un commit Anatomía > git log -1 commit 7b092a2be4f147aa7878cb37e1228a5c38cd3949 Author: John Ronald Reuel Tolkien <root@middle-earth.com> Date: Wed Aug 14 13:20:19 1922 +0100 Not a dwarf's story I put some trolls too. And elves with pointy ears. Not sure about the whole thing with the ring, though. HEAD master  7b09 
  • 26. Remotes > git remote add "endor" "https://github.com/jrrt/hobbit.git" > git push -u "endor" master:heru HEAD master endor/heru  7b09 
  • 27. Branches > git branch "dragon" HEAD > git checkout "dragon" > git checkout -b "dragon" HEAD dragon master  7b09 
  • 28. Indexando > git add "the-hobbit.txt" > git commit -m "Enter Pryftan, the motherfu**ing dragon" HEAD dragon master  7b09   69d2 
  • 29. ¿Corregimos? > sed -i "s/Pryftan/Smaug/g" "the-hobbit.txt" > git add "the-hobbit.txt" > git commit --amend -m "Enter Smaug, the motherfu**ing dragon" HEAD dragon master  7b09   69d2   1c6a 
  • 30. Diferencias > git diff 7b09 diff --git i/the-hobbit.txt w/the-hobbit.txt --- i/the-hobbit.txt +++ w/the-hobbit.txt @@ -1 +1 @@ -Pryftan really did laugh, a devastating sound which shook Bilbo to the floor +Smaug really did laugh, a devastating sound which shook Bilbo to the floor HEAD dragon master  7b09   69d2   1c6a 
  • 31. Pull > git checkout master > git pull From https://github.com/jrrt/hobbit.git 7b092a2..62e3342 heru -> endor/heru Updating 7b092a2..62e3342 Fast-forward dragon  1c6a  HEAD master  5b3f  endor/heru  7b09   a9af   62e3 
  • 32. Merge > git merge --no-ff "dragon" dragon  1c6a   7b09  HEAD master  5b3f   692e   a9af   62e3 
  • 33. GitHub
  • 34. GitHub
  • 35. GitHub es… ● ● ● ● “Build software better, together” Servicio de gestión avanzada GIT Mejoras en la colaboración Social
  • 36. Herramientas ● ● ● ● ● Pull Request Comentarios Issues Labels Wiki
  • 37. own à la GitHub Markd ● ● ● ● Filtro de texto plano a HTML Mejoras GitHub Específicas GitHub Emojis!
  • 38. Shortcuts [?] [s] [j] [g] [t] [w] es tu tecla amiga / [/] busca en tus repos/repo actual / [k] selección arriba/abajo + [c] / [i] / [p] ir al código/issues/PRs buscar por nombre de fichero cambiar rama
  • 39. GIT avanzado
  • 40. os de comando Tip ● Porcelain ○ user-friendly ○ add, commit, pull, … ● Plumbing ○ script-friendly ○ cat-file, update-ref, merge-base, …
  • 41. Revisiones > > > > > > git git git git git git rev-parse rev-parse rev-parse rev-parse rev-parse rev-parse refname~{num} refname^{num} refname@{time} refname@{num} refname@{u} @{-num} // go up num levels // choose from multiple parents // where the ref pointed time ago // where the ref pointed num entries ago // refname's upstream // <n>th branch checked out before current
  • 42. Revisiones > > > > > > git git git git git git rev-parse rev-parse rev-parse rev-parse rev-parse rev-parse HEAD^ master^2 master^^ dragon~2 dragon@{1} master@{u} 62e3 5b3f a9af 7b09 1c6a 62e3 dragon  1c6a  HEAD master  5b3f   692e  endor/heru  7b09   a9af   62e3 
  • 43. de encuentro Punto > git merge-base master dragon 7b092a2be4f147aa7878cb37e1228a5c38cd3949 dragon  1c6a   7b09  HEAD master  5b3f   a9af   62e3 
  • 44. tando commits Lis > git log --graph --decorate --pretty=oneline * b964a8d (dragon) Merged Edith fixes | | * 62e3342 (endor/heru) Rewording for better readability | * a9af710 Fixed typos in first draft * | 5b3ffe4 Add more dwarfs * | 1c6ad34 Enter Smaug, the motherfu**ing dragon |/ * 7b092a2 Not a dwarf's story
  • 45. tando commits Lis > git log -S "Gandalf" --pretty="%h %s by %aN %ar" 62e3342 Rewording for better readability by JRRTolkien 2 hours ago 7b092a2 Not a dwarf's story by JRRTolkien 3 days ago > git log --oneline -- LICENSE 7b092a2 Not a dwarf's story
  • 46. Moviéndose > git reset --soft "62e3" > git reset --hard "62e3" > git reset "62e3" HEAD master dragon  1c6a   7b09  HEAD master  5b3f   a9af   62e3   692e 
  • 47. ando la historia Cambi > git rebase "7b09" "dragon" --onto "master" dragon  1c6a  HEAD master  5b3f   692e   7b09   a9af  HEAD dragon master  7b09   a9af   62e3   62e3   12b3   48c2 
  • 48. quito a poco Po > git checkout master > git cherry-pick 1c6a 5b3f dragon  1c6a  HEAD master  5b3f   7b09   a9af   62e3  HEAD master  12b3   48c2  HEAD master dragon  7b09   a9af   62e3   12b3   48c2 
  • 49. Marcha atrás > git checkout -f HEAD > git reset --hard > git clean -df > git revert "a9af" > git rebase --interactive HEAD "a9af"~
  • 50. interactivo Rebase > git rebase --interactive 7b09 dragon pick 5b3f Bilbo is chased by the dragon pick 1c6a Dragon description # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell
  • 51. El alijo… > git stash -u -k > git lol stash@{0} *-. f571325 WIP on master: | | | * b4bea53 untracked files on master: | * a9af710 index on master: |/ * 012f62b (master) Enter Smaug, the motherfu**ing dragon … > git stash apply > git stash drop > git stash pop
  • 52. Reflog > git reflog dragon ab4a dragon@{0}: rebase finished: refs/heads/dragon onto ab4a 5b3f dragon@{1}: reset: moving to HEAD~ b964 dragon@{2}: pull endor heru: Merge made by the 'recursive' strategy.
  • 53. Alias > git config alias.lol "log --graph --decorate --oneline" --global > git lol * b964a8d (dragon) | | * 62e3342 (endor/heru) Rewording for better readability | * a9af710 Fixed typos in first draft * | 5b3ffe4 Add more dwarfs * | 1c6ad34 Enter Smaug, the motherfu**ing dragon |/ * 7b092a2 Not a dwarf's story
  • 54. Alias > git config alias.replay '!f() { git rebase "$(git merge-base HEAD "$1")" "$1" --onto HEAD }; f' > git replay dragon
  • 55. s de interés Enlace ● ● ● ● official website visual git reference git workflows xphere@github/system/git
  • 56. THE END jugo a GIT Sacándole ocalipsis ervivencia para el ap Manual de sup // Porque con zombies todo suena más molón // TO DO: Añadir zombies zombie