$30 off During Our Annual Pro Sale. View details »

「Gitによるバージョン管理」の執筆者によるGit勉強会か講演会 / git bundle

「Gitによるバージョン管理」の執筆者によるGit勉強会か講演会 / git bundle

「Gitによるバージョン管理」の執筆者によるGit勉強会か講演会 / git bundle についてのスライドです。

Nobuhiro Iwamatsu

February 29, 2012
Tweet

More Decks by Nobuhiro Iwamatsu

Other Decks in Programming

Transcript

  1. . . . . . . ʮGitʹΑΔόʔδϣϯ؅ཧʯͷ ࣥචऀʹΑΔGitษڧձ͔ߨԋձ git bundle

    ʹ͍ͭͯޠͬͯΈΔ ؠদ ৴༸ iwamatsu@nigauri.org (@iwamatsu) 2012 ೥ 2 ݄ 28 ೔
  2. . . . . . . ຊ͔Βফ͞ΕͨηΫγϣϯ: git bundle git

    bundle.....
  3. . . . . . . ϦϙδτϦ΁ͷΞΫηε • Git ͸෼ࢄϦϙδτϦܕ

  4. . . . . . . ϦϙδτϦ΁ͷΞΫηε • Git ͸෼ࢄϦϙδτϦܕ

    • Git ͸ϦϙδτϦ΁ͷΞΫηεํ๏͕ଟ༷
  5. . . . . . . ϦϙδτϦ΁ͷΞΫηε • Git ͸෼ࢄϦϙδτϦܕ

    • Git ͸ϦϙδτϦ΁ͷΞΫηεํ๏͕ଟ༷ • gitɺWebDAVɺfileɺrsyncɺsshɺmailɺetcɻ
  6. . . . . . . GitΛ࢖ͬͨ։ൃ

  7. . . . . . . GitΛ࢖ͬͨ։ൃ A:ʮϦϙδτϦͷߋ৽͍ͨ͠ͷͰύον௖ଷɻ ʯ

  8. . . . . . . GitΛ࢖ͬͨ։ൃ A:ʮϦϙδτϦͷߋ৽͍ͨ͠ͷͰύον௖ଷɻ ʯ B:ʮαʔόʹϦϙδτϦஔ͍ͱ͍͔ͨΒ͔ͦ͜Β

    pull Ͱ͖ΔΑɻ ʯ
  9. . . . . . . GitΛ࢖ͬͨ։ൃ A:ʮϦϙδτϦͷߋ৽͍ͨ͠ͷͰύον௖ଷɻ ʯ B:ʮαʔόʹϦϙδτϦஔ͍ͱ͍͔ͨΒ͔ͦ͜Β

    pull Ͱ͖ΔΑɻ ʯ A:ʮ͋ʔɺ͔͜͜Βͦ͜ͷωοτϫʔΫʹܨ͛Β Εͳ͍ΜͩΑͶɻ ʯ
  10. . . . . . . GitΛ࢖ͬͨ։ൃ A:ʮϦϙδτϦͷߋ৽͍ͨ͠ͷͰύον௖ଷɻ ʯ B:ʮαʔόʹϦϙδτϦஔ͍ͱ͍͔ͨΒ͔ͦ͜Β

    pull Ͱ͖ΔΑɻ ʯ A:ʮ͋ʔɺ͔͜͜Βͦ͜ͷωοτϫʔΫʹܨ͛Β Εͳ͍ΜͩΑͶɻ ʯ Bʮ͸͊ʁ(AA ུʯ
  11. . . . . . . GitΛ࢖ͬͨ։ൃ Ͳ͜Ͱ΋ LAN ΍ΠϯλʔωοτͰͭͳ͕͍ͬͯ

    Δͱ͸ݶΒͳ͍ɻ
  12. . . . . . . LAN΍Πϯλʔωοτܦ༝ͰϦϙδτ ϦΛߋ৽Ͱ͖ͳ͍

  13. . . . . . . LAN΍Πϯλʔωοτܦ༝ͰϦϙδτ ϦΛߋ৽Ͱ͖ͳ͍ • ࣾ಺/άϧʔϓձࣾͰͷ͕͠ΒΈ

  14. . . . . . . LAN΍Πϯλʔωοτܦ༝ͰϦϙδτ ϦΛߋ৽Ͱ͖ͳ͍ • ࣾ಺/άϧʔϓձࣾͰͷ͕͠ΒΈ

    • ։ൃִ཭෦԰
  15. . . . . . . LAN΍Πϯλʔωοτܦ༝ͰϦϙδτ ϦΛߋ৽Ͱ͖ͳ͍ • ࣾ಺/άϧʔϓձࣾͰͷ͕͠ΒΈ

    • ։ൃִ཭෦԰ • ϋʔυ΢ΣΞͷ੍ݶʢRS232C ͔͠ແ͍ͱ͔ʣ
  16. . . . . . . LAN΍Πϯλʔωοτܦ༝ͰϦϙδτ ϦΛߋ৽Ͱ͖ͳ͍ • ࣾ಺/άϧʔϓձࣾͰͷ͕͠ΒΈ

    • ։ൃִ཭෦԰ • ϋʔυ΢ΣΞͷ੍ݶʢRS232C ͔͠ແ͍ͱ͔ʣ • ਅ໘໨ͳ࿩ɺωοτϫʔΫ࢖͏ΑΓૣ͍৔߹ɻ
  17. . . . . . . LAN΍Πϯλʔωοτܦ༝ͰϦϙδτ ϦΛߋ৽Ͱ͖ͳ͍ • ࣾ಺/άϧʔϓձࣾͰͷ͕͠ΒΈ

    • ։ൃִ཭෦԰ • ϋʔυ΢ΣΞͷ੍ݶʢRS232C ͔͠ແ͍ͱ͔ʣ • ਅ໘໨ͳ࿩ɺωοτϫʔΫ࢖͏ΑΓૣ͍৔߹ɻ • ͦ͜ͰεχʔΧʔωοτϫʔΫΛ࢖͏ɻ
  18. . . . . . . εχʔΧʔωοτϫʔΫ ෳ਺୆ͷίϯϐϡʔλ͕͋ͬͯ΋ɺ௨৴ωοτ ϫʔΫ͕ಋೖ͞Ε͍ͯͳ͍ঢ়ଶΛεχʔΧʔωο τͱ͍͏ɻ͜ͷݴ༿͸͋Δίϯϐϡʔλ͔Βผͷ

    ίϯϐϡʔλʹσʔλΛૹΔඞཁ͕Ͱ͖ͨͱ͖ʹ ϑϩοϐʔσΟεΫ΍ MO ͳͲΛ࣋ͬͨਓ͕ؒ૸ Γճ͍ͬͯΔঢ়ଶΛൽ೑ͬͯʮεχʔΧʔΛཤ͍ ͨਓؒΛഔհʹͨ͠ωοτϫʔΫʯͱ͍͏ҙຯͰ ͚ͭΒΕͨɻ1 1Wikipedia:εχʔΧʔωοτϫʔΫ͔Βൈਮ
  19. . . . . . . ϦϙδτϦ΁ͷΞΫηε • Git ͸෼ࢄϦϙδτϦܕ

  20. . . . . . . ϦϙδτϦ΁ͷΞΫηε • Git ͸෼ࢄϦϙδτϦܕ

    • Git ͸ϦϙδτϦ΁ͷΞΫηεํ๏͕ଟ༷
  21. . . . . . . ϦϙδτϦ΁ͷΞΫηε • Git ͸෼ࢄϦϙδτϦܕ

    • Git ͸ϦϙδτϦ΁ͷΞΫηεํ๏͕ଟ༷ • gitɺWebDAVɺfileɺrsyncɺsshɺmailɺetcɻ
  22. . . . . . . ϦϙδτϦ΁ͷΞΫηε • Git ͸෼ࢄϦϙδτϦܕ

    • Git ͸ϦϙδτϦ΁ͷΞΫηεํ๏͕ଟ༷ • gitɺWebDAVɺfileɺrsyncɺsshɺmailɺetcɻ • ΋ͪΖΜεχʔΧʔωοτϫʔΫ΋ͩͬʂ
  23. . . . . . .

  24. . . . . . . εχʔΧʔωοτϫʔΫରԠ • εχʔΧʔωοτϫʔΫΛ࢖͏ʹ͸ʁ

  25. . . . . . . εχʔΧʔωοτϫʔΫରԠ • εχʔΧʔωοτϫʔΫΛ࢖͏ʹ͸ʁ •

    git bundle Λ࢖͏ɻ
  26. . . . . . . git bundle • bundle

    : ଋɺଋঢ়ߏ଄
  27. . . . . . . git bundle • bundle

    : ଋɺଋঢ়ߏ଄ • ओͳػೳ: ίϛοτΛଋʹవΊͯɺϑΝΠϧ ʹग़ྗ͢Δ
  28. . . . . . . git bundle

  29. . . . . . . git bundle

  30. . . . . . . bundle Πϝʔδ࡞੒ git bundle

    create $ git bundle create ../update.bundle v1.0..v2.0 Counting objects: 20, done. Delta compression using up to 4 threads. Compressing objects: 100% (13/13), done. Writing objects: 100% (19/19), 1.24 KiB, done. Total 19 (delta 10), reused 0 (delta 0)
  31. . . . . . . git bundle

  32. . . . . . . εχʔΧʔωοτ ࡞੒͞ΕͨΠϝʔδΛUSBϝϞϦͳͲʹ ೖΕͯɺϦϙδτϦઌʹҠಈ

  33. bundle Πϝʔδద༻ . . . . . .

  34. bundle Πϝʔδద༻ ͦͷલʹ bundle Πϝʔδݕূ . . . . .

    .
  35. . . . . . . bundle Πϝʔδݕূ git bundle

    verify
  36. . . . . . . bundle Πϝʔδݕূ git bundle

    verify
  37. . . . . . . bundle Πϝʔδݕূ git bundle

    verify
  38. . . . . . . bundle Πϝʔδݕূ $ git

    bundle verify ../update.bundle The bundle contains 1 ref 187a8a3a13118a52d799998219e9c8f25e1bf9a3 refs/tags/v2.0 The bundle requires these 1 ref 13f2c31dddc39cb0ae6814cc83ce91f240914446 Add data1 ../update.bundle is okay
  39. . . . . . . ݕূΤϥʔʹͳΔύλʔϯ

  40. . . . . . . ݕূΤϥʔʹͳΔύλʔϯ

  41. . . . . . . ݕূΤϥʔʹͳΔύλʔϯ

  42. . . . . . . ݕূΤϥʔʹͳΔύλʔϯ ΤϥʔʹͳΔɻ $ git

    bundle verify ../update.bundle error: Repository lacks these prerequisite commits: error: 902bbbc4f0bfc2cec2335123cc590fa600a239c3 Add data1
  43. . . . . . . ݕূΤϥʔʹͳΔύλʔϯ

  44. bundle ΠϝʔδͷऔΓࠐΈ . . . . . .

  45. . . . . . . bundle ΠϝʔδͷऔΓࠐΈ • git

    pull git pull ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git fetch git fetch ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git remote git remote update ϦϞʔτϦϙδτϦ໊
  46. . . . . . . bundle ΠϝʔδͷऔΓࠐΈ • git

    pull git pull ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git fetch git fetch ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git remote git remote update ϦϞʔτϦϙδτϦ໊ • ϦϑΝϨϯεΛࢦఆ͢Δඞཁ͕͋Δ
  47. . . . . . . bundle ΠϝʔδͷऔΓࠐΈ • git

    pull git pull ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git fetch git fetch ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git remote git remote update ϦϞʔτϦϙδτϦ໊ • ϦϑΝϨϯεΛࢦఆ͢Δඞཁ͕͋Δ
  48. . . . . . . bundle Πϝʔδ಺ʹ͋ΔϦϑΝϨϯε Λग़ྗ git

    bundle list-heads
  49. . . . . . . bundle Πϝʔδ಺ʹ͋ΔϦϑΝϨϯε Λग़ྗ $

    git bundle list-heads ../update.bundle 187a8a3a13118a52d799998219e9c8f25e1bf9a3 refs/tags/v2.0 ../update.bundle ʹ͸ϦϑΝϨϯεͱͯ͠ refs/tags/v2.0 ͷΈؚ͕·Ε͍ͯΔ͜ͱ͕Θ ͔Δɻ
  50. . . . . . . bundle ΠϝʔδͷऔΓࠐΈ • git

    pull git pull ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git fetch git fetch ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git remote git remote update ϦϞʔτϦϙδτϦ໊ • ϦϑΝϨϯεΛࢦఆ͢Δඞཁ͕͋Δ
  51. . . . . . . bundle ΠϝʔδͷऔΓࠐΈ • git

    pull git pull ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git fetch git fetch ϦϞʔτϦϙδτϦ ϦϑΝϨϯε • git remote git remote update ϦϞʔτϦϙδτϦ໊ • ϦϑΝϨϯεΛࢦఆ͢Δඞཁ͕͋Δ • bundle ϑΝΠϧ͸ϦϞʔτϦϙδτϦͱͯ͠ ѻ͑Δ
  52. . . . . . . git pull ϦϑΝϨϯεΛࢦఆ͠ͳ͍৔߹: $

    git pull ../update.bundle fatal: Couldn’t find remote ref HEAD HEAD ͕ bunlde ϑΝΠϧʹؚ·Εͯͳ͍ͷͰΤ ϥʔʹͳΔɻ
  53. . . . . . . git pull ϦϑΝϨϯεΛࢦఆͨ͠৔߹: $

    git pull ../update.bundle refs/tags/v2.0 Receiving objects: 100% (19/19), done. Resolving deltas: 100% (10/10), done. From ../update.bundle * tag v2.0 -> FETCH_HEAD Updating c74b792..fea9e6f Fast-forward data3 | 1 + data4 | 1 + data5 | 1 + dataA | 1 + dataB | 1 + dataC | 1 + 6 files changed, 6 insertions(+), 0 deletions(-) create mode 100644 data3 ʢলུʣ
  54. . . . . . . git pull

  55. . . . . . . git pull

  56. . . . . . . git pull • git

    pull → Ϛʔδ͕ى͖ΔՄೳੑɻ • ϦϞʔτϦϙδτϦͱͯ͠औΓѻ͏ͷ͕ΊΜ Ͳ͏͍͘͞ɻ FETCH HEAD Λ࢖ͬͯ࡞ۀ͢Δඞཁ͕͋Δɻ • HEAD ͕ͳ͍৔߹ɺϦϑΝϨϯεΛࢦఆ͢Δ ඞཁ͕͋Δɻ
  57. . . . . . . git fetch $ git

    fetch ../update.bundle fatal: Couldn’t find remote ref HEAD $ git fetch ../update.bundle refs/tags/v2.0 Receiving objects: 100% (19/19), done. Resolving deltas: 100% (10/10), done. From ../update.bundle * tag v2.0 -> FETCH_HEAD
  58. . . . . . . git-fetch

  59. . . . . . . git fetch

  60. . . . . . . git fetch • git

    fetch → Ϛʔδ͸ى͖ͳ͍ɻ • HEAD ͕ͳ͍৔߹ɺϦϑΝϨϯεΛࢦఆ͢Δ ඞཁ͕͋Δɻ
  61. . . . . . . git remote $ git

    remote add bundle-data ../update.bundle $ git remote update bundle-data Fetching bundle-data From ../bundle-20120228 * [new tag] v2.0 -> v2.0
  62. . . . . . . git remote

  63. . . . . . . git remote

  64. . . . . . . git remote • git

    remote → Ϛʔδ͸ى͖ͳ͍ • ϦϑΝϨϯεΛࢦఆ͢Δඞཁ͕ͳ ͍ɻ.git/config ͷ refspec ݟͯ͘ΕΔ • remote ʹઃఆ͓͚ͯ͠͹࣍ճ͔Β͸ϑΝΠϧ ίϐʔͯ͠ɺgit remote update Ͱ OK • git remote ࢖͍·͠ΐ͏
  65. . . . . . . bundle ΠϝʔδͷऔΓࠐΈ ϩʔΧϧϦϙδτϦʹऔΓࠐΉ৔߹: •

    git pull • git fetch • git remote Λ࢖͏ɻ
  66. . . . . . . ͦͷଞͷίϚϯυ • git bundle

    unbundle
  67. . . . . . . git bundle unbundle Git

    ΦϒδΣΫτΛ git index-pack Λ࢖ͬͯ .git/objects ҎԼʹల։͢Δɻ $ git bundle unbundle ../update.bundle Git ΦϒδΣΫτਥޚ༻ୡπʔϧɻ fetch ͳͲ͸ඞཁͳ΋ͷ͚ͩΛरͬͯల։͢Δɻ
  68. . . . . . . λά΍ϒϥϯν͸Ͳ͏͢Δͷʁ • bundle ࡞੒࣌ʹऔΓࠐΈ͍ͨλά΍ϒϥϯν

    Λࢦఆ͢Δ • શͯͷλά͸ --tags Λࢦఆ͢Δ • શͯͷϒϥϯν͸--branch Λࢦఆ͢Δ • શͯͷϦϑΝϨϯεΛऔΓࠐΈ͍ͨ৔߹ʹ͸ --all Λࢦఆ͢Δ
  69. . . . . . . λά΍ϒϥϯν͸Ͳ͏͢Δͷʁ

  70. . . . . . . λά΍ϒϥϯν͸Ͳ͏͢Δͷʁ $ git bundle

    create ../update.bundle v1.0..v2.0 \ --tags --branches
  71. . . . . . . λά΍ϒϥϯν͸Ͳ͏͢Δͷʁ

  72. . . . . . . ࣅͨΑ͏ͳػೳ git format-patch ͸Ͳ͏

    ͳͷʁ • git format-patch : ύονΛ git send-email Ͱ ૹ৴Ͱ͖ΔܗࣜͰग़ྗ͢Δɻ
  73. . . . . . . ࣅͨΑ͏ͳػೳ git format-patch ͸Ͳ͏

    ͳͷʁ • git format-patch : ύονΛ git send-email Ͱ ૹ৴Ͱ͖ΔܗࣜͰग़ྗ͢Δɻ ໰୊: • େྔͷύονͰॲཧͱ؅ཧ͕ΊΜͲ͏͘ ͍͞ɻ • ώϡʔϚϯΤϥʔͰଞͷϦϙδτϦͱͷ੔߹ ੑ͕औΕͳ͘ͳΔՄೳੑ͕͋Δɻ • ϒϥϯνɺλάͳͲΛऔΓѻ͏͜ͱ͕Ͱ͖ ͳ͍ɻ
  74. . . . . . . ͚Ͳɺ࢖͏͜ͱͳΜͯແ͍ΑͶʁ

  75. . . . . . . ͚Ͳɺ࢖͏͜ͱͳΜͯແ͍ΑͶʁ ͔ͩΒϖʔδ࡟Δͱ͖ʹফ͞ΕͨΜͩΑ....

  76. . . . . . . ͚Ͳɺ࢖͏͜ͱͳΜͯແ͍ΑͶʁ

  77. . . . . . . ͚Ͳɺ࢖͏͜ͱͳΜͯແ͍ΑͶʁ ·ɺ·͔͞ tar ͰݻΊͯόοΫΞοϓͱ͔ͱ͔

    ΍ͬͯͳ͍ΑͶ....
  78. . . . . . . ϦϙδτϦͷόοΫΞοϓ bundle ։࢝ҐஔΛࢦఆ͠ͳ͍৔߹ɺҰ൪࠷ॳͷί ϛοτ͔Βࢦఆͨ͠ίϛοτ·ͰవΊͯ͘ΕΔɻ

    $ git bundle create ../backup.bundle HEAD --all
  79. . . . . . . ϦϙδτϦͷόοΫΞοϓ

  80. . . . . . . ϦϙδτϦͷόοΫΞοϓ

  81. . . . . . . ϦϙδτϦͷόοΫΞοϓ Git ͷ git

    ϦϙδτϦΛ όοΫΞοϓͯ͠Έͨɻ ॲཧ/ѹॖํࣜ ॲཧ଎౓ αΠζ tar/gz 2.207s 37MB tar/xz 22.477s 36MB git bundle 3.531s 27MB
  82. . . . . . . ϦϙδτϦͷόοΫΞοϓ Git ͷ git

    ϦϙδτϦΛ όοΫΞοϓͯ͠Έͨɻ ॲཧ/ѹॖํࣜ ॲཧ଎౓ αΠζ tar/gz 2.207s 37MB tar/xz 22.477s 36MB git bundle 3.531s 27MB git bundle େউརʂ
  83. . . . . . . ·ͱΊ • Git ͸෼ࢄϦϙδτϦܕ

  84. . . . . . . ·ͱΊ • Git ͸෼ࢄϦϙδτϦܕ

    • Git ͸ϦϙδτϦ΁ͷΞΫηεํ๏͕ଟ༷
  85. . . . . . . ·ͱΊ • Git ͸෼ࢄϦϙδτϦܕ

    • Git ͸ϦϙδτϦ΁ͷΞΫηεํ๏͕ଟ༷ • εχʔΧωοτϫʔΫ΋ରԠ
  86. . . . . . . ·ͱΊ • Git ͸෼ࢄϦϙδτϦܕ

    • Git ͸ϦϙδτϦ΁ͷΞΫηεํ๏͕ଟ༷ • εχʔΧωοτϫʔΫ΋ରԠ • git bundle ॏཁ • ϦϙδτϦόοΫΞοϓʹ͸ git bundle
  87. . . . . . . ࣭໰ Կ͔࣭໰͸͋Γ·͔͢ʁ