Upgrade to Pro — share decks privately, control downloads, hide ads and more …

知っておいてほしいGitの本当の基礎 / Let's know Git

知っておいてほしいGitの本当の基礎 / Let's know Git

コミットの連なりと.gitの中身について @miyaoka

社内勉強会向けに作った資料

Masaya Kazama

March 24, 2017
Tweet

More Decks by Masaya Kazama

Other Decks in Technology

Transcript

  1. ஌͓͍ͬͯͯ΄͍͠ (JUͷຊ౰ͷجૅ

  2. ίϛοτͷ࿈ͳΓͱHJUͷத਎ ʹ͍ͭͯ  ˏNJZBPLB

  3. தڃऀʙॳ৺ऀ޲͚

  4. ͱɺࢥ͍͍ͨ

  5. ૢ࡞ͷઆ໌ͱ͔ ͦ͏͍͏͜ͱΑΓ΋

  6. ࠜຊతʹ(JUͷ࡞ΓΛ ஌Γ·͠ΐ͏

  7. (JUͷίϛοτάϥϑ

  8. FHGBDFCPPLSFBDU

  9. ͍͍ͬͨͲ͏΍ͬͯ ද͍ࣔͯ͠ΔͷͰ͠ΐ͏͔ʁ

  10. ίϛοτͱ͸ JECCG BVUIPSOBNF EBUF "EEJOEFYQBHF JOEFYIUNM JNBHFQOH NBJOKT

  11. ίϛοτͱ͸ JECCG BVUIPSOBNF EBUF "EEJOEFYQBHF JOEFYIUNM JNBHFQOH NBJOKT ͦΕͧΕϢχʔΫͳ*%Λ࣋ͪɺ ࡞੒ऀ΍೔෇৘ใɺ

    ίϛοτϝοηʔδΛ࣋ͪɺ ϑΝΠϧ಺༰Λ࣋ͪ·͢
  12. ίϛοτͱ͸ ͦͯ͠ ਌ͷίϛοτ*%Λ࣋ͪ·͢ JECCG QBSFOUTEFDD BVUIPSOBNF EBUF "EEJOEFYQBHF JOEFYIUNM JNBHFQOH

    NBJOKT
  13. ༨ஊɿ(JUͰ࢖ΘΕΔ*% w 4)"ؔ਺ʢ੬ऑੑʣʹΑΔϢχʔΫͳ*% w ಉ͡಺༰ͳΒಉ͡*%ʹͳΔ w ϑϧͰจࣈͷਐ਺ʹͳΔ͕ɺઌ಄਺จࣈ෼͋ Ε͹ࣝผͰ͖ΔͷͰେ఍จࣈఔ౓ʹলུͰ͖Δ

  14. w ਌ίϛοτΛḷ͍ͬͯ͘͜ͱͰπϦʔʹͳΓ·͢ ίϛοτͷ࿈ͳΓ JECCG QBSFOUTEFDD JEEFDD QBSFOUTGCD JEGCD QBSFOUTDFGF JEDFGF

    QBSFOUTBCG JEBCG QBSFOUTGEB
  15. ίϛοτͷ࿈ͳΓ ࠷ॳͷίϛοτ

  16. Ͱ΋ɺͲ͔͜ΒḷΔʁ

  17. ίϛοτͷ࿈ͳΓ ࠷ॳͷίϛοτ w ֤ίϛοτ͸਌ํ޲ʹḷ͍ͬͯ͘ͷͰɺ࠷ॳͷίϛο τ͸ى఺ʹͳΒͳ͍

  18. πϦʔͷى఺ NBTUFS EFWFMPQ W )&"%

  19. ى఺ͱͳΔ΋ͷ )&"% ϒϥϯν λά

  20. )&"%͔ΒḷΔ NBTUFS EFWFMPQ W )&"%

  21. )&"%ͱ͸ w ݱࡏϦϙδτϦͷͲ͜ͷίϛοτΛࢦ͍ͯ͠Δͷ͔ͱ͍ ͏ϙΠϯλ w جຊతʹ͸બ୒தͷϒϥϯνΛࢦ͢ʢϒϥϯνͰ͸ͳ͘ ௚઀ίϛοτ*%Λࢦఆ͢Δ͜ͱ΋Ͱ͖Δ͕ܯࠂ͕ग़Δʣ w ͜ͷϙΠϯλͷࢦࣔ͢͠ίϛοτͱϫʔΫϑΝΠϧͱͷ ࠩ෼͕දࣔ͞ΕΔ

  22. ϒϥϯνͷ੾Γସ͑ NBTUFS EFWFMPQ W )&"% HJUDIFDLPVUNBTUFS

  23. )&"%ˠϒϥϯνˠίϛοτ w ʮ)&"%ˠ͍ͣΕ͔ͷϒϥϯνˠίϛοτʯͱࢀর͢Δ ͜ͱͰઌ಄ͷίϛοτ͕ܾ·ΓɺίϛοτπϦʔΛḷΔ ͜ͱ͕Ͱ͖Δ w ϒϥϯν΍λά͸ίϛοτΛࢦࣔ͢͠ᐼͷΑ͏ͳ΋ͷʢϒ ϥϯν͸Ҡಈ͢Δ͕λά͸ݻఆʣ w ϒϥϯνΛ੾Γସ͑Δͱ͍͏ͷ͸ɺ)&"%͕ࢀর͢Δϒ

    ϥϯνΛม͑Δͱ͍͏͜ͱ
  24. Ͳ͔͜Β΋ࢀর͞Εͳ͍ίϛοτ NBTUFS EFWFMPQ W )&"%

  25. Ͳ͔͜Β΋ࢀর͞Εͳ͍ίϛοτ w )&"%ͳͲ͔ΒḷΕͳ͍ίϛοτ͸πϦʔʹද ࣔ͞Εͳ͍ w ͭ·ΓπϦʔʹදࣔ͞Ε͍ͯΔ΋ͷ͕શͯͷί ϛοτͰ͸ͳ͍ w Ͳ͔͜Β΋ḷΕͳ͍ίϛοτ͸ͦͷ͏ͪࣗಈత ʹফڈ͞ΕΔ

  26. ࢀর͞Εͳ͘ͳΔίϛοτྫ $ # " "EEJOFEYpMF )&"%

  27. ίϛοτϝοηʔδͷUZQP "EEJOFEYpMF ·͕ͪ͑ͨʂ $ # " )&"% ʘ͸͔͍ͣ͠ʗ

  28. BNFOEͰϝοηʔδमਖ਼ "EEJOEFYpMF $ # " )&"% ʘͳ͓ͬͨʗ HJUDPNNJUŠBNFOENl"EEJOEFYpMFz

  29. ͜ͷͱ͖ɺ࣮ࡍ͸ʜ "EEJOEFYpMF $ # " "EEJOFEYpMF $` )&"% w ίϛοτΛॻ͖׵͑ͨͷͰ͸ͳ͘ɺผͷ৽͍͠ί

    ϛοτΛ࡞ͬͯͦͪΒʹ)&"%ΛҠ͍ͯ͠Δ w ݩͷίϛοτ͸ḷΕͳ͘ͳͬͨͷͰπϦʔද͔ࣔ Β͸ফ͑Δ w ͳͷͰॻ͖׵ΘͬͨΑ͏ʹΈ͑Δ w දࣔ͞Εͳ͘ͳͬͯ΋಺෦తʹ࢒Γଓ͚Δ
  30. աڈͷίϛοτΛॻ͖׵͑Δ $ # " PMENTH )&"% % & ͪΐͬͱ͚ͩ͜͜मਖ਼͍ͨ͠

  31. SFCBTF $ #` " OFXNTH )&"% % & ʘͳ͓ͬͨʔʗ HJUSFCBTFJʢུ

  32. Ͱ΋ຊ౰͸͜͏ͳͬͯΔ $ # " PMENTH )&"% % & $` #`

    %` &` OFXNTH
  33. มΘͬͨͷ͸Ұ෦ͳΜ͔ͩΒ ͚ͩ͜͜Ͱ͍͍Μ͡Όʁ $ # " PMENTH )&"% % & #`

    OFXNTH
  34. ͜͏͍͏΋ͷͳΜͰ͢ $ # " % & $` #` %` &`

    w Ұ౓࡞ͬͨίϛοτ͸ʢجຊతʹʣॻ͖׵ ΘΒͳ͍ w ৽͍͠ίϛοτ͸*%͕มΘΔ w ਌*%͕มΘΔͷͰɺͨͱ͑ͦͷଞͷ಺༰͕ શ͘ಉ͡Ͱ΋৽͍͠ίϛοτͱͯ͠࡞Γ௚ ͞ΕΔ w ͭ·ΓͲ͔͜࡞Γ௚ͨ͠Β͔ͦ͜Βޙͷί ϛοτ͸࿈࠯తʹશͯ࡞Γ௚͠ʹͳΔ มߋͨ͠ ਌*%͕มΘͬͨ ͷ͔ͦ͏͔ ਌*%͕มΘͬͨ ͷ͔ͦ͏͔ ਌*%͕มΘͬͨ ͷ͔ͦ͏͔
  35. ϒϥϯνΛ ফͪ͠Όͬͨ

  36. ͜Μͳϒϥϯν $ # " GFBU % & EFWFMPQ

  37. ϒϥϯν࡟আ $ # " % & EFWFMPQ HJUCSBODI%GFBU ʘ͋ͬɺ΍ͬͺΓඞཁͩͬͨʗ

  38. େৎ෉ ͦΕͰ΋औΓग़͢ खஈ͸͋Γ·͢

  39. ϒϥϯνΛ෇͚௚͢ $ # " % & EFWFMPQ HJUSFqPH CCB)&"%!\^ʜ FCDDF)&"%!\^ʜ

    GCCC)&"%!\^ʜ HJUCSBODIOFXCSBODICCB OFXCSBODI w ίϛοτ͸ݟ͑ͳ͘ͳ͚ͬͨͩͰɺ࣮ࡍʹ͸ ফ͍͑ͯͳ͍ w )&"%ͷϩάͳͲ͔Βίϛοτ*%Λݟ͚ͭग़ ͯͦ͜͠ʹ৽ͨʹϒϥϯνͳͲΛ͚ͭΕ͹· ͨදࣔ͞ΕΔΑ͏ʹͳΔ
  40. ͜͜·Ͱͷ ·ͱΊ

  41. w ϦϙδτϦͷத਎͸͜Μͳײ͡ ϙΠϯλͱίϛοτ܈ NBTUFS EFWFMPQ W )&"% ೖޱͱͳΔϙΠϯλ ແ਺ͷίϛοτ

  42. Πϝʔδతʹ ͍͍ͩͨΘ͔Γ·ͨ͠ Ͷ

  43. ͔͜͜Β͸ ࣮ࡍͷத਎Λ ݟͯཧղ͠·͠ΐ͏

  44. HJU

  45. (JUͷॳظԽ XPSLJOHEJSFDUPSZ HJUJOJU

  46. (JUͷॳظԽ SFGT HJU )&"% PCKFDUT XPSLJOHEJSFDUPSZ MPHT HJUJOJU HJUσΟϨΫτϦ͕࡞੒͞Εɺ͞ΒʹͦͷதʹۭσΟϨΫτϦ ܈͕࡞੒͞ΕΔʢ͜͜Ͱ͸ओཁͳ΋ͷͷΈʹهࡌΛলུʣ

  47. ϑΝΠϧΛ࡞੒ͯ͠௥Ճ XPSLJOHEJSFDUPSZ pMFUYU FDIPpMFDPOUFOUpMFUYU HJUBEEpMFUYU

  48. ϑΝΠϧΛ࡞੒ͯ͠௥Ճ SFGT HJU )&"% JOEFY PCKFDUT E B XPSLJOHEJSFDUPSZ pMFUYU

    MPHT FDIPpMFDPOUFOUpMFUYU HJUBEEpMFUYU 4)"ͷ*%͔ΒʮσΟϨΫτ Ϧ໊ ϑΝΠϧ໊ʯͷϑΝΠϧ ʹ಺༰͕֨ೲ͞ΕΔ ݱࡏεςʔδ͞Ε͍ͯΔϑΝΠ ϧπϦʔ৘ใ ͜ͷ಺༰ͱϫʔΫϑΝΠϧΛ ൺֱͯࠩ͠෼͕දࣔ͞ΕΔ
  49. ࠷ॳͷίϛοτ XPSLJOHEJSFDUPSZ pMFUYU HJUDPNNJUNlJOJUJBMDPNNJUz

  50. ࠷ॳͷίϛοτ SFGT IFBET NBTUFS HJU )&"% JOEFY PCKFDUT FC DDF

     B E  XPSLJOHEJSFDUPSZ pMFUYU MPHT )&"% SFGT IFBET NBTUFS HJUDPNNJUNlJOJUJBMDPNNJUz lFCDDFz ϒϥϯν͕ࢦࣔ͠͠ ͍ͯΔઌͷίϛοτ *% lSFGSFGTIFBET NBTUFSz ݱࡏϦϙδτϦͷͲ͜ Λࢀর͍ͯ͠Δͷ͔ͱ ͍͏ϙΠϯλ FCDDFNBTUFS!\^DPNNJU JOJUJBM JOJUJBMDPNNJU FCDDF)&"%!\^DPNNJU JOJUJBM JOJUJBMDPNNJU
  51. w (JUΦϒδΣΫτͷߏ੒ΛݟͯΈΑ͏ HJUDBUpMFQFCDDF USFFBFCCDGECBEBDEEB BVUIPS.BTBZB,B[BNB  DPNNJUUFS.BTBZB,B[BNB  JOJUJBMDPNNJU HJUDBUpMFQB

    CMPCEBCDBBBEGFpMFUYU HJUDBUpMFQE pMFDPOUFOU PCKFDUT FC DDF  B E  ࠷ॳͷίϛοτͷத਎ $PNNJU0CKFDU ίϛοτ৘ใ 5SFF0CKFDU ϑΝΠϧϦετ৘ใ #MPC0CKFDU ϑΝΠϧͷத਎ NBTUFS
  52. ϒϥϯνͷ࡞੒ XPSLJOHEJSFDUPSZ pMFUYU HJUCSBODIEFW

  53. ϒϥϯνͷ࡞੒ SFGT IFBET NBTUFS EFW HJU )&"% JOEFY PCKFDUT FC

    DDF  B E  XPSLJOHEJSFDUPSZ pMFUYU MPHT )&"% SFGT IFBET NBTUFS EFW HJUCSBODIEFW FCDDF ϒϥϯνʹ৽͍͠ϙΠϯλ͕௥Ճ͞ΕΔɻ ͜ͷ࣌఺Ͱ͸NBTUFSͱಉҰ FCDDFEFW!\^CSBODI$SFBUFEGSPNNBTUFS
  54. ϒϥϯνͷ੾Γସ͑ XPSLJOHEJSFDUPSZ pMFUYU HJUDIFDLPVUEFW

  55. ϒϥϯνͷ੾Γସ͑ SFGT IFBET NBTUFS EFW HJU )&"% JOEFY PCKFDUT FC

    DDF  B E  XPSLJOHEJSFDUPSZ pMFUYU MPHT )&"% SFGT IFBET NBTUFS EFW HJUDIFDLPVUEFW SFGSFGTIFBETEFW )&"%ͷࢀরઌΛมߋ͢Δ ͜ͱͰϒϥϯν͕มΘΔ FCDDF)&"%!\^DIFDLPVUNPWJOHGSPNNBTUFSUPEFW FCDDF)&"%!\^DPNNJU JOJUJBM JOJUJBMDPNNJU
  56. ճ໨ͷίϛοτ XPSLJOHEJSFDUPSZ pMFUYU pMFUYU FDIPpMF@UYUpMFUYU HJUBEEpMFUYU HJUDPNNJUNlBEEpMFz

  57. ճ໨ͷίϛοτ SFGT IFBET NBTUFS EFW HJU )&"% JOEFY PCKFDUT G

    CCC FG BGFF  CE FC  E XPSLJOHEJSFDUPSZ pMFUYU pMFUYU MPHT )&"% SFGT IFBET NBTUFS EFW FDIPpMF@UYUpMFUYU HJUBEEpMFUYU HJUDPNNJUNlBEEpMFz GCCC)&"%!\^DPNNJUBEEpMF FCDDF)&"%!\^DIFDLPVUNPWJOHGSPNNBTUFSUPEFW FCDDF)&"%!\^DPNNJU JOJUJBM JOJUJBMDPNNJU GCCCEFW!\^DPNNJUBEEpMF FCDDFEFW!\^CSBODI$SFBUFEGSPNNBTUFS GCCC ৽͍͠ίϛοτʹϙΠϯλ ͕ॻ͖׵ΘΔ
  58. w ॳճͱҧ͏ͱ͜Ζ HJUDBUpMFQGC USFFCEFBBEFCCFCCBC QBSFOUFCDDFDCGFFFGCDF BVUIPS.BTBZB,B[BNB  DPNNJUUFS.BTBZB,B[BNB  BEEpMF

    HJUDBUpMFQCE CMPCEBCDBBBEGFpMFUYU CMPCFGBGFFDFFDGGEEEGCFpMFUYU PCKFDUT G CCC  CE E  FG BGFF ճ໨ͷίϛοτͷத਎ ਌ͷίϛοτ*%͕௥Ճ͞Εͨ ෳ਺ϑΝΠϧʹͳͬͨ
  59. NBTUFSʹϚʔδ XPSLJOHEJSFDUPSZ pMFUYU pMFUYU HJUDIFDLPVUNBTUFS HJUNFSHFEFW

  60. NBTUFSʹϚʔδ SFGT IFBET NBTUFS EFW HJU )&"% JOEFY PCKFDUT 

    CCB G FG  FC  E XPSLJOHEJSFDUPSZ pMFUYU pMFUYU MPHT )&"% SFGT IFBET NBTUFS EFW HJUDIFDLPVUNBTUFS HJUNFSHFEFW CCB)&"%!\^NFSHFEFW.FSHFNBEFCZUIF SFDVSTJWFTUSBUFHZ FCDDF)&"%!\^DIFDLPVUNPWJOHGSPNEFWUPNBTUFS GCCC)&"%!\^DPNNJUBEEpMF FCDDF)&"%!\^DIFDLPVUNPWJOHGSPNNBTUFSUPEFW FCDDF)&"%!\^DPNNJU JOJUJBM JOJUJBMDPNNJU CCBNBTUFS!\^NFSHFEFW.FSHFNBEFCZUIF SFDVSTJWFTUSBUFHZ FCDDFNBTUFS!\^DPNNJU JOJUJBM JOJUJBMDPNNJU CCB ৽͍͠ίϛοτΛࢀর SFGSFGTIFBETNBTUFS ݩͷNBTUFSϒϥϯνʹ໭Δ
  61. w Ϛʔδίϛοτͷத਎ΛݟͯΈΑ͏ HJUDBUpMFQC USFFCEFBBEFCCFCCBC QBSFOUFCDDFDCGFFFGCDF QBSFOUGCCCCCECBFFGBCEECB BVUIPS.BTBZB,B[BNB  DPNNJUUFS.BTBZB,B[BNB 

    .FSHFCSBODIEFW PCKFDUT  CCB  CE E  FG BGFF ճ໨ͷίϛοτ HJUDBUpMFQCE CMPCEBCDBBBEGFpMFUYU CMPCFGBGFFDFFDGGEEEGCFpMFUYU ϑΝΠϧ಺༰͸͖ͬ͞ͱಉ͡ Ϛʔδίϛοτ͸਌Λͭ࣋ͭ ࠷ॳͷίϛοτ ճ໨ͷίϛοτ
  62. Ϛʔδίϛοτͷ਌ͭ " % $ # EFWFMPQ NBTUFS IFBE HJUDBUpMFQC USFFCEFBBEFCCFCCBC

    QBSFOUFCDDFDCGFFFGCDF QBSFOUGCCCCCECBFFGBCEECB FCDDF GCCC w ͭ໨ͷQBSFOU͸IFBEଆ w ͭ໨͸NFSHFࢦఆଆ
  63. ·ͱΊ w ࡞ۀதͷϑΝΠϧ͸ͱʹ͔͘ίϛοτ͓ͯ͜͠͏ w Ұ౓ίϛοτͨ͠಺༰͸ɺSFTFUŠIBSEͨ͠Γϒ ϥϯνফͯ͠ݟ͑ͳ͘ͳͬͯ΋ࣦΘΕ͍ͯͳ͍ w ϒϥϯν͸ͨͩͷᐼ w ؾܰʹ࡞ͬͨΓফͨ͠Γ͠Α͏

    w ίϛοτ͸ʢݪଇʣॻ͖׵͑ෆՄ w ৽͘͠࡞Γ௚͍ͯ͠ΔΘ͚ͳͷͰɺϦϞʔτͷଞͷ ࡞ۀऀͱಉظ͢Δͱ͖͸஫ҙ
  64. ͜ΕͰ΋͏ ෼͔Γ·ͨ͠ Ͷ