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ͷຊ౰ͷجૅ

    View full-size slide

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

    ˏNJZBPLB

    View full-size slide

  3. தڃऀʙॳ৺ऀ޲͚

    View full-size slide

  4. ͱɺࢥ͍͍ͨ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  8. FHGBDFCPPLSFBDU

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  11. ίϛοτͱ͸
    JECCG
    BVUIPSOBNF
    EBUF
    "EEJOEFYQBHF
    JOEFYIUNM
    JNBHFQOH
    NBJOKT
    ͦΕͧΕϢχʔΫͳ*%Λ࣋ͪɺ
    ࡞੒ऀ΍೔෇৘ใɺ
    ίϛοτϝοηʔδΛ࣋ͪɺ
    ϑΝΠϧ಺༰Λ࣋ͪ·͢

    View full-size slide

  12. ίϛοτͱ͸
    ͦͯ͠
    ਌ͷίϛοτ*%Λ࣋ͪ·͢
    JECCG
    QBSFOUTEFDD
    BVUIPSOBNF
    EBUF
    "EEJOEFYQBHF
    JOEFYIUNM
    JNBHFQOH
    NBJOKT

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  24. Ͳ͔͜Β΋ࢀর͞Εͳ͍ίϛοτ
    NBTUFS
    EFWFMPQ
    W
    )&"%

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  29. ͜ͷͱ͖ɺ࣮ࡍ͸ʜ
    "EEJOEFYpMF
    $
    #
    "
    "EEJOFEYpMF
    $`
    )&"%
    w ίϛοτΛॻ͖׵͑ͨͷͰ͸ͳ͘ɺผͷ৽͍͠ί
    ϛοτΛ࡞ͬͯͦͪΒʹ)&"%ΛҠ͍ͯ͠Δ
    w ݩͷίϛοτ͸ḷΕͳ͘ͳͬͨͷͰπϦʔද͔ࣔ
    Β͸ফ͑Δ
    w ͳͷͰॻ͖׵ΘͬͨΑ͏ʹΈ͑Δ
    w දࣔ͞Εͳ͘ͳͬͯ΋಺෦తʹ࢒Γଓ͚Δ

    View full-size slide

  30. աڈͷίϛοτΛॻ͖׵͑Δ
    $
    #
    "
    PMENTH
    )&"%
    %
    &
    ͪΐͬͱ͚ͩ͜͜मਖ਼͍ͨ͠

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  34. ͜͏͍͏΋ͷͳΜͰ͢
    $
    #
    "
    %
    &
    $`
    #`
    %`
    &`
    w Ұ౓࡞ͬͨίϛοτ͸ʢجຊతʹʣॻ͖׵
    ΘΒͳ͍
    w ৽͍͠ίϛοτ͸*%͕มΘΔ
    w ਌*%͕มΘΔͷͰɺͨͱ͑ͦͷଞͷ಺༰͕
    શ͘ಉ͡Ͱ΋৽͍͠ίϛοτͱͯ͠࡞Γ௚
    ͞ΕΔ
    w ͭ·ΓͲ͔͜࡞Γ௚ͨ͠Β͔ͦ͜Βޙͷί
    ϛοτ͸࿈࠯తʹશͯ࡞Γ௚͠ʹͳΔ
    มߋͨ͠
    ਌*%͕มΘͬͨ
    ͷ͔ͦ͏͔
    ਌*%͕มΘͬͨ
    ͷ͔ͦ͏͔
    ਌*%͕มΘͬͨ
    ͷ͔ͦ͏͔

    View full-size slide

  35. ϒϥϯνΛ
    ফͪ͠Όͬͨ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  40. ͜͜·Ͱͷ
    ·ͱΊ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  44. (JUͷॳظԽ
    XPSLJOHEJSFDUPSZ HJUJOJU

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  47. ϑΝΠϧΛ࡞੒ͯ͠௥Ճ
    SFGT
    HJU
    )&"%
    JOEFY
    PCKFDUT
    E
    B
    XPSLJOHEJSFDUPSZ
    pMFUYU
    MPHT
    FDIPpMFDPOUFOUpMFUYU
    HJUBEEpMFUYU
    4)"ͷ*%͔ΒʮσΟϨΫτ
    Ϧ໊ϑΝΠϧ໊ʯͷϑΝΠϧ
    ʹ಺༰͕֨ೲ͞ΕΔ
    ݱࡏεςʔδ͞Ε͍ͯΔϑΝΠ
    ϧπϦʔ৘ใ
    ͜ͷ಺༰ͱϫʔΫϑΝΠϧΛ
    ൺֱͯࠩ͠෼͕දࣔ͞ΕΔ

    View full-size slide

  48. ࠷ॳͷίϛοτ
    XPSLJOHEJSFDUPSZ
    pMFUYU
    HJUDPNNJUNlJOJUJBMDPNNJUz

    View full-size slide

  49. ࠷ॳͷίϛοτ
    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

    View full-size slide

  50. 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

    View full-size slide

  51. ϒϥϯνͷ࡞੒
    XPSLJOHEJSFDUPSZ
    pMFUYU
    HJUCSBODIEFW

    View full-size slide

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

    B
    E

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

    View full-size slide

  53. ϒϥϯνͷ੾Γସ͑
    XPSLJOHEJSFDUPSZ
    pMFUYU
    HJUDIFDLPVUEFW

    View full-size slide

  54. ϒϥϯνͷ੾Γସ͑
    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

    View full-size slide

  55. ճ໨ͷίϛοτ
    XPSLJOHEJSFDUPSZ
    pMFUYU
    pMFUYU
    FDIPpMF@UYUpMFUYU
    HJUBEEpMFUYU
    HJUDPNNJUNlBEEpMFz

    View full-size slide

  56. ճ໨ͷίϛοτ
    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
    ৽͍͠ίϛοτʹϙΠϯλ
    ͕ॻ͖׵ΘΔ

    View full-size slide

  57. w ॳճͱҧ͏ͱ͜Ζ
    HJUDBUpMFQGC
    USFFCEFBBEFCCFCCBC
    QBSFOUFCDDFDCGFFFGCDF
    BVUIPS.BTBZB,B[BNB
    DPNNJUUFS.BTBZB,B[BNB
    BEEpMF
    HJUDBUpMFQCE
    CMPCEBCDBBBEGFpMFUYU
    CMPCFGBGFFDFFDGGEEEGCFpMFUYU
    PCKFDUT
    G
    CCC

    CE
    E

    FG
    BGFF
    ճ໨ͷίϛοτͷத਎
    ਌ͷίϛοτ*%͕௥Ճ͞Εͨ
    ෳ਺ϑΝΠϧʹͳͬͨ

    View full-size slide

  58. NBTUFSʹϚʔδ
    XPSLJOHEJSFDUPSZ
    pMFUYU
    pMFUYU
    HJUDIFDLPVUNBTUFS
    HJUNFSHFEFW

    View full-size slide

  59. 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ϒϥϯνʹ໭Δ

    View full-size slide

  60. w Ϛʔδίϛοτͷத਎ΛݟͯΈΑ͏
    HJUDBUpMFQC
    USFFCEFBBEFCCFCCBC
    QBSFOUFCDDFDCGFFFGCDF
    QBSFOUGCCCCCECBFFGBCEECB
    BVUIPS.BTBZB,B[BNB
    DPNNJUUFS.BTBZB,B[BNB
    .FSHFCSBODIEFW
    PCKFDUT

    CCB

    CE
    E

    FG
    BGFF
    ճ໨ͷίϛοτ
    HJUDBUpMFQCE
    CMPCEBCDBBBEGFpMFUYU
    CMPCFGBGFFDFFDGGEEEGCFpMFUYU
    ϑΝΠϧ಺༰͸͖ͬ͞ͱಉ͡
    Ϛʔδίϛοτ͸਌Λͭ࣋ͭ
    ࠷ॳͷίϛοτ
    ճ໨ͷίϛοτ

    View full-size slide

  61. Ϛʔδίϛοτͷ਌ͭ
    "
    %
    $
    #
    EFWFMPQ
    NBTUFS
    IFBE
    HJUDBUpMFQC
    USFFCEFBBEFCCFCCBC
    QBSFOUFCDDFDCGFFFGCDF
    QBSFOUGCCCCCECBFFGBCEECB
    FCDDF
    GCCC
    w ͭ໨ͷQBSFOU͸IFBEଆ
    w ͭ໨͸NFSHFࢦఆଆ

    View full-size slide

  62. ·ͱΊ
    w ࡞ۀதͷϑΝΠϧ͸ͱʹ͔͘ίϛοτ͓ͯ͜͠͏
    w Ұ౓ίϛοτͨ͠಺༰͸ɺSFTFUŠIBSEͨ͠Γϒ
    ϥϯνফͯ͠ݟ͑ͳ͘ͳͬͯ΋ࣦΘΕ͍ͯͳ͍
    w ϒϥϯν͸ͨͩͷᐼ
    w ؾܰʹ࡞ͬͨΓফͨ͠Γ͠Α͏
    w ίϛοτ͸ʢݪଇʣॻ͖׵͑ෆՄ
    w ৽͘͠࡞Γ௚͍ͯ͠ΔΘ͚ͳͷͰɺϦϞʔτͷଞͷ
    ࡞ۀऀͱಉظ͢Δͱ͖͸஫ҙ

    View full-size slide

  63. ͜ΕͰ΋͏
    ෼͔Γ·ͨ͠
    Ͷ

    View full-size slide