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

Git中級者になるためのrebase入門 / Introduction to rebase t...

takasp
April 16, 2021
54

Git中級者になるためのrebase入門 / Introduction to rebase to become an intermediate Git user

takasp

April 16, 2021
Tweet

Transcript

  1. ௌߨର৅ऀ • Git ͷ add, commit, push ͳͲͷجຊίϚϯυ͸ཧղ ͍ͯ͠Δਓ •

    rebase ͸஌Βͳ͍ਓ • rebase ͸஌ͬͯΔ͚Ͳɺ࢖ͬͨ͜ͱͳ͍ɺ࢖͚ͬͨͲ Α͘෼͔Βͳ͍ਓ • rebase ΛͲ͏͍͏࣌ʹ࢖ͬͨΒྑ͍͔෼͔Βͳ͍ਓ
  2. git merge ίϚϯυͷ͓͞Β͍ • ผͷϒϥϯνͷมߋΛऔΓࠐΉ৔߹ • Ϛʔδͷ݁Ռ͸େ͖͘ 3 ͭʹ෼͚ΒΕΔ •

    Fast Forward : ยํͷϒϥϯν͕ݹ͘ɺऔΓࠐΈઌͷϒϥϯν͕ͦ ͷ··औΓࠐΉ৔߹ • Auto Merge : ಉ͡ϑΝΠϧͷมߋ͕͋ΓɺࣗಈͰϚʔδͰ͖Δ৔߹ • Conflict : ಉ͡ϑΝΠϧͷಉ͡ՕॴΛมߋ͍ͯͯ͠ɺGit ʹ͸൑அ͕ Ͱ͖ͳ͍৔߹
  3. git rebase -i (--interactive) • ҎԼͷૢ࡞͕ߦ͑Δ • drop : ίϛοτΛ࡟আ͢Δ

    • exec : ίϛοτʹରͯ͠ shell Λ࢖ͬͯίϚϯυΛ࣮ߦ͢Δ • fixup : ίϛοτΛ·ͱΊΔ • squash : ίϛοτΛ·ͱΊͯɺίϛοτϝοηʔδΛฤू͢Δ • edit : ίϛοτʹมߋΛՃ͑Δ • reword : ίϛοτϝοηʔδΛฤू͢Δ • pick : ίϛοτΛݱঢ়ҡ࣋͢Δ
  4. merge ͱ rebase ͷҧ͍ • merge • ίϛοτཤྺΛഁյ͠ͳ͍ • ෆཁͳίϛοτ΍Ϛʔδίϛοτ͕ଟ͍ͱ

    ཤྺΛӾཡͮ͠Β͍ • rebase • ίϛοτཤྺ͕៉ྷʹͳΔ • ҧ͏ίϛοτͱͯ͠࠶࡞੒͞ΕΔ
  5. ϦϞʔτ௥੻ϒϥϯνͱ ্ྲྀϒϥϯν ϩʔΧϧϦϙδτϦ ϦϞʔτϦϙδτϦ NBJO UBTL PSJHJONBJO PSJHJOUBTL NBJO UBTL

    ϦϞʔτ௥੻ϒϥϯν origin #͸"ͷ্ྲྀϒϥϯν "͸#ͷϦϞʔτ௥੻ϒϥϯν B B A A ϩʔΧϧ ϒϥϯν
  6. git pull ͷڍಈ • git pull = git fetch +

    git merge • git fetch : ϦϞʔτϦϙδτϦͷมߋΛ ϦϞʔτ௥੻ϒϥϯνʹऔΓࠐΉ • git pull ίϚϯυͰҾ਺Λলུͯ͠΋ಈ࡞͢Δ ͷ͸ɺ্ྲྀϒϥϯν͕ઃఆ͞Ε͍ͯΔͨΊ
  7. git pull ͷڍಈ ϩʔΧϧϦϙδτϦ ϦϞʔτϦϙδτϦ NBJO UBTL PSJHJONBJO PSJHJOUBTL NBJO

    UBTL ϦϞʔτ௥੻ϒϥϯν origin ϩʔΧϧ ϒϥϯν git merge git fetch git pull
  8. git pull -r (--rebase) • git merge ͷڍಈΛ git rebase

    ʹม͑Δ͜ͱ͕Ͱ͖Δ • git pull ࣌ʹൃੜՄೳੑͷ͋ΔϚʔδίϛοτΛ ࡞੒ͨ͘͠ͳ͍৔߹΍ίϛοτϩάΛ៉ྷʹ ͠ͳ͕ΒมߋΛऔΓࠐΈ͍ͨ৔߹ʹ࢖༻͢Δ • git rebase ͷίϛοτվมͷՄೳੑ͕͋ΔͷͰɺ push લͳͲͷར༻ʹݶΔ΄͏͕ྑ͍
  9. git pull -r ͷڍಈ ϩʔΧϧϦϙδτϦ ϦϞʔτϦϙδτϦ NBJO UBTL PSJHJONBJO PSJHJOUBTL

    NBJO UBTL ϦϞʔτ௥੻ϒϥϯν origin ϩʔΧϧ ϒϥϯν git rebase git fetch git pull -r