Git E Seu Amigo

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Git E Seu Amigo - Presentation Transcript

    1. Git é seu amigo Celestino Gomes Saturday, September 12, 2009 1
    2. O quê? • Criado em 2005 por Linus Torvalds • Necessidade, linux-kernel-devs • Originalmente, era um engine para VCS • Fluxo de trabalho distribuído • Prevenção de corrupção acidental • Alta performance Saturday, September 12, 2009 2
    3. Características básicas • Controle de versão distribuido (DVCS) • Gerenciamento de conteúdo e não arquivos • Branches como unidade de trabalho • SHA1 para associação e verificação • Staging index • Não é o subversion Saturday, September 12, 2009 3
    4. Como funciona? Saturday, September 12, 2009 4
    5. Diretório .git • Diretório .git na raíz de cada projeto • Arquivos de configuração (.git/config) • Index (.git/index) • Hooks (.git/hooks) • Object Database (.git/objects) • References (.git/refs) Saturday, September 12, 2009 5
    6. Object Database • Quatro tipos de objetos: • Blob, Tree, Commit e Tag • Todos registrados/gravados da mesma maneira Saturday, September 12, 2009 6
    7. Object Database - Loose format conteudo header + conteudo “2e6f9b0d5885b6010f9167787445617f553a735f” zlib(header + conteudo) .git/objects/2e/6f9b0d5885b6010f9167787445617f553a735f Saturday, September 12, 2009 7
    8. Object Database - Packed format .git/objects/2e/6f9b0d5885b6010f9167787445617f553a735f .git/objects/0b/772ec8eb9ae8952c3c1e56a9ffbe49385cc83a .git/objects/72/16b02627bc3d6ef57008f7ff67f0f8f13f488e git-gc .git/objects/pack/pack-0bc9a42eb66d7ae36bf44af8ff5a3888e8a02d12.idx .git/objects/pack/pack-0bc9a42eb66d7ae36bf44af8ff5a3888e8a02d12.pack Saturday, September 12, 2009 8 Digamos que os objetos listados referenciem o mesmo arquivo, com conjuntos pequenos de diferenças geradas ao longo do tempo. Usar uma ferramenta de manutenção (git-gc, por exemplo) vai compactar os objetos e armazená-los em ‘/pack’.
    9. Object Database - Blob Rakefile blob: 2e6f9b active_content.rb blob: 7034fe active_content_spec.rb blob: a738fc Saturday, September 12, 2009 9
    10. Object Database - Tree / tree: 1fba94 Rakefile blob: 2e6f9b /lib tree: 3ef95a active_content.rb blob: 7034fe /spec tree: 34ba74 active_content_spec.rb blob: a738fc Saturday, September 12, 2009 10
    11. Object Database - Commit commit: 8d1ab4 / tree: 1fba94 Rakefile blob: 2e6f9b /lib tree: 3ef95a active_content.rb blob: 7034fe /spec tree: 34ba74 active_content_spec.rb blob: a738fc Saturday, September 12, 2009 11
    12. Object Database - Commit commit: 8d1ab4 commit: 61db26 / tree: 1fba94 tree: 1fba94 Rakefile blob: 2e6f9b blob: 41d300 /lib tree: 3ef95a tree: 3ef95a active_content.rb blob: 7034fe blob: 7034fe /spec tree: 34ba74 tree: 34ba74 active_content_spec.rb blob: a738fc blob: 2a03fb Saturday, September 12, 2009 12
    13. Object Database - Tag tag: 6ee1f2 commit: 8d1ab4 / tree: 1fba94 Rakefile blob: 2e6f9b /lib tree: 3ef95a active_content.rb blob: 7034fe /spec tree: 34ba74 active_content_spec.rb blob: a738fc Saturday, September 12, 2009 13
    14. Object Database - Resumindo Saturday, September 12, 2009 14
    15. Object Database - Resumo • Blob é o menor objeto do git • Tree contém Trees e Blobs • Commit contém Commits, Trees e Blobs • Tags contém/apontam um Commit Saturday, September 12, 2009 15
    16. References .git/refs/heads/master master HEAD commit: 8d1ab4 / tree: 1fba94 Rakefile blob: 2e6f9b /lib tree: 3ef95a active_content.rb blob: 7034fe /spec tree: 34ba74 active_content_spec.rb blob: a738fc Saturday, September 12, 2009 16 Um branch é um ponteiro para um commit. Quando se avança um branch adicionando commits, o que está acontecendo, por baixo dos panos, é mudar o ponteiro do branch para um novo commit.
    17. Staging Index lib.rb Untracked $ git add lib.rb lib.rb Staged $ git commit -m “lib.rb” lib.rb Commited Saturday, September 12, 2009 17
    18. Flow básico Saturday, September 12, 2009 18
    19. Criação de repositórios Criando um novo repositório $ rails my_blog ... $ cd my_blog $ git init $ git add . $ git commit -m “Initial commit” Criando um repositório a partir de um outro $ git clone git://github.com/tinogomes/my_blog_app_with_bug.git $ cd my_blog_app_with_bug $ git branch master Saturday, September 12, 2009 19
    20. Trabalhando em um branch remoto $ cd my_blog_app_with_bug $ git checkout -b refactoring origin/refactoring ... após modificações $ echo tmp > .gitignore $ git add . $ git commit -m “outras modificacoes” $ git pull $ git push origin refactoring Saturday, September 12, 2009 20
    21. Indo além do flow básico Saturday, September 12, 2009 21
    22. Adicionando arquivos $ git add <dir> $ git add <dir>/<arquivo> $ git add *.rb $ git add . (cuidado) Saturday, September 12, 2009 22
    23. Trabalhando com branch local $ cd my_blog_app_with_bug $ git branch meu_branch_local ... $ git checkout master $ git pull . master $ git push origim master $ git branch -d meu_branch_local Saturday, September 12, 2009 23
    24. Navegando pelo histórico $ git log --stat commit 7f5a85113381e8c0d16e4679c4e5a81a4eb000b8 Author: Celestino Gomes <celestino@HDU15121-ADIGITAL.local> Date: Sat Sep 12 02:22:52 2009 -0300 Initial commit README | 243 ++ Rakefile | 10 + app/controllers/application_controller.rb | 10 + app/helpers/application_helper.rb | 3 + config/boot.rb | 110 + ... test/performance/browsing_test.rb | 9 + test/test_helper.rb | 38 + 41 files changed, 8452 insertions(+), 0 deletions(-) Saturday, September 12, 2009 24
    25. Navegando pelo histórico $ git log -p --no-merges commit 7f5a85113381e8c0d16e4679c4e5a81a4eb000b8 Author: Celestino Gomes <celestino@HDU15121-ADIGITAL.local> Date: Sat Sep 12 02:22:52 2009 -0300 Initial commit diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb new file mode 100644 index 0000000..4b60558 --- /dev/null +++ b/test/performance/browsing_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' +require 'performance_test_help' + +# Profiling results for each test method are written to tmp/performance. +class BrowsingTest < ActionController::PerformanceTest + def test_homepage + get '/' + end +end Saturday, September 12, 2009 25
    26. Navegando pelo histórico $ git log --pretty=oneline 7f5a85113381e8c0d16e4679c4e5a81a4eb000b8 Initial commit $ git blame app/helpers/application_helper.rb ^7f5a851 (Celestino Gomes 2009-09-12 02:22:52 -0300 1) module ApplicationHelper ^7f5a851 (Celestino Gomes 2009-09-12 02:22:52 -0300 2) end Saturday, September 12, 2009 26
    27. Manipulando o índice Remove do stage index $ git reset [<commit>] Limpa os arquivos, inclusive os unstagged $ git reset --hard [<commit>] Coloca os arquivos de volta para o stage index $ git reset --soft [<commit>] Permite alterar o último commit $ git commit --amend Saturday, September 12, 2009 27 <commit> - default HEAD
    28. A diferença entre merge e rebase master sprint_branch C1 C2 C4 C3 C5 Saturday, September 12, 2009 28
    29. A diferença entre merge e rebase master sprint_branch C1 $ git checkout master $ git pull . sprint_branch C2 C4 ou $ git checkout master C3 C5 $ git fetch $ git merge sprint_branch C6 merge commit Saturday, September 12, 2009 29
    30. A diferença entre merge e rebase master C1 $ git checkout master $ git pull --rebase . sprint_branch C2 C4 ou $ git checkout master C3 C5 $ git fetch $ git rebase sprint_branch C4’ C5’ Saturday, September 12, 2009 30
    31. Usando o stash $ git stash $ git stash list $ git stash show stash@{0} $ git stash apply $ git stash drop stash@{0} Saturday, September 12, 2009 31
    32. Revertendo commits $ git revert <commit_hash> $ git revert -n <commit_hash> Saturday, September 12, 2009 32 -n para deixar a reversão no index
    33. Buscando por bugs $ git bisect start [<bad> [<good>]] $ git bisect good | bad [<rev>] $ git bisect skip [(<rev>|<range>)] $ git bisect reset $ git bisect run <cmd | script> Saturday, September 12, 2009 33 1) Primeiro é necessário identificar pontos (commits) bons e ruins para começar a caça. Usar $ git log 2) $ git bisect run my_script - Note that the "run" script (my_script in the above example) should exit with code 0 in case the current source code is good. Exit with a code between 1 and 127 (inclusive), except 125, if the current source code is bad.
    34. Limpando a sujeira do dia-a-dia Remover arquivos/diretórios não trackeados $ git clean -d -f Remover um branch remoto $ git push origin :<branch_remoto> Limpar todo o stash $ git stash clear Saturday, September 12, 2009 34 clean para remover arquivos/diretórios não trackeados, push origin :<branch> limpa branches remotos, stash para limpar todo o stash
    35. Funciona no Windows? • Somente através do cygwin ou msysGit Saturday, September 12, 2009 35
    36. Referências • http://git.or.cz/gitwiki/GitDocumentation • http://www.kernel.org/pub/software/scm/git/docs/ • http://blog.tinogomes.com/2008/05/11/instalando-e-usando-git- no-windows-xp/ • http://github.com Saturday, September 12, 2009 36
    37. Perguntas Saturday, September 12, 2009 37
    38. Mais sobre mim • http://blog.tinogomes.com Saturday, September 12, 2009 38
    39. Obrigado! Saturday, September 12, 2009 39

    + Celestino  GomesCelestino Gomes, 2 months ago

    custom

    268 views, 0 favs, 0 embeds more stats

    Essa foi a apresentação usada no RailsForKids 200 more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 268
      • 268 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 13
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories