Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Git中級者になるためのrebase入門 / Introduction to rebase t...
Search
takasp
April 16, 2021
0
52
Git中級者になるためのrebase入門 / Introduction to rebase to become an intermediate Git user
takasp
April 16, 2021
Tweet
Share
More Decks by takasp
See All by takasp
監視のための統計入門 / Introduction to Statistics for Monitoring
takasp
0
100
Google App Engineを始めよう / Getting Started with Google App Engine
takasp
0
47
GitHubで始めるdotfiles管理 / Getting started with GitHub for dotfiles management
takasp
0
33
第三回 Datadog 共有会 / Datadog Sharing 3rd
takasp
0
70
第二回 Datadog 共有会 / Datadog Sharing 2nd
takasp
0
72
Datadog 共有会 / Datadog Sharing
takasp
1
49
Git ハンズオン Part 1 / Git Handson Part 1
takasp
0
55
Docker ハンズオン 基礎編2 / Docker Handson Basic 2
takasp
1
88
Docker ハンズオン 基礎編1 / Docker Handson Basic 1
takasp
1
170
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Done Done
chrislema
181
16k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Docker and Python
trallard
40
3.1k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Why Our Code Smells
bkeepers
PRO
334
57k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.8k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Transcript
Git தڃऀʹͳΔͨΊͷ rebase ೖ # ୈ9ճϥϯνLT @takasp 20214݄16
ࣗݾհ • @takasp a.k.a. tackey • ࡛ۄݝੜ·Ε౦ژҭͪ • झຯɿΪλʔɺϐΞϊ •
ྖҬɿόοΫΤϯυ ɹɹɹΠϯϑϥ
ௌߨରऀ • Git ͷ add, commit, push ͳͲͷجຊίϚϯυཧղ ͍ͯ͠Δਓ •
rebase Βͳ͍ਓ • rebase ͬͯΔ͚Ͳɺͬͨ͜ͱͳ͍ɺ͚ͬͨͲ Α͔͘Βͳ͍ਓ • rebase ΛͲ͏͍͏࣌ʹͬͨΒྑ͍͔͔Βͳ͍ਓ
git rebase ίϚϯυͱ • Ұ࿈ͷίϛοτཤྺΛमਖ਼͢ΔίϚϯυ • ྫ͑ • ҎલͷίϛοτϝοηʔδΛमਖ਼͢Δ •
ෳͷίϛοτΛ·ͱΊΔ • ෆཁʹͳͬͨίϛοτΛআ͢Δ
git merge
git merge ίϚϯυͷ͓͞Β͍ • ผͷϒϥϯνͷมߋΛऔΓࠐΉ߹ • Ϛʔδͷ݁Ռେ͖͘ 3 ͭʹ͚ΒΕΔ •
Fast Forward : ยํͷϒϥϯν͕ݹ͘ɺऔΓࠐΈઌͷϒϥϯν͕ͦ ͷ··औΓࠐΉ߹ • Auto Merge : ಉ͡ϑΝΠϧͷมߋ͕͋ΓɺࣗಈͰϚʔδͰ͖Δ߹ • Conflict : ಉ͡ϑΝΠϧͷಉ͡ՕॴΛมߋ͍ͯͯ͠ɺGit ʹஅ͕ Ͱ͖ͳ͍߹
git mergeʢFast Forwardʣ • લʹਐΉ͚ͩ 1 2 3 task main
git mergeʢFast Forwardʣ • લʹਐΉ͚ͩ 1 2 3 task main
merge
git mergeʢAuto Mergeʣ • Ϛʔδίϛοτ͕ൃߦ͞ΕΔ 1 2 3 4 task
main
git mergeʢAuto Mergeʣ • Ϛʔδίϛοτ͕ൃߦ͞ΕΔ 1 2 3 merge 4
task main 5
• ಉ͡ߦΛฤू͍ͯͯ͠ Git ͕ղܾͰ͖ͳ͍ git mergeʢConflictʣ 1 2 3 4
task main
• ಉ͡ߦΛฤू͍ͯͯ͠ Git ͕ղܾͰ͖ͳ͍ git mergeʢConflictʣ 1 2 3 merge
4 task main Conflict
git rebase
git mergeʢAuto Mergeʣ࠶ܝ • Ϛʔδίϛοτ͕ൃߦ͞ΕΔ 1 2 3 merge 4
task main 5
git rebase • task ϒϥϯν͕ main ϒϥϯνʹ࠶ద༻͞Εɺ Fast Forward ϚʔδͰ͖Δ
1 2 3 4 task main
git rebase • task ϒϥϯν͕ main ϒϥϯνʹ࠶ద༻͞Εɺ Fast Forward ϚʔδͰ͖Δ
1 2 3 rebase 4 task main 4’
git rebase -i (--interactive) • ҎԼͷૢ࡞͕ߦ͑Δ • drop : ίϛοτΛআ͢Δ
• exec : ίϛοτʹରͯ͠ shell ΛͬͯίϚϯυΛ࣮ߦ͢Δ • fixup : ίϛοτΛ·ͱΊΔ • squash : ίϛοτΛ·ͱΊͯɺίϛοτϝοηʔδΛฤू͢Δ • edit : ίϛοτʹมߋΛՃ͑Δ • reword : ίϛοτϝοηʔδΛฤू͢Δ • pick : ίϛοτΛݱঢ়ҡ࣋͢Δ
merge ͱ rebase ͷҧ͍ • merge • ίϛοτཤྺΛഁյ͠ͳ͍ • ෆཁͳίϛοτϚʔδίϛοτ͕ଟ͍ͱ
ཤྺΛӾཡͮ͠Β͍ • rebase • ίϛοτཤྺ͕៉ྷʹͳΔ • ҧ͏ίϛοτͱͯ͠࠶࡞͞ΕΔ
git rebase ͷҙ • ϦϞʔτϦϙδτϦʹެ։ͨ͠ίϛοτ rebase ͠ͳ͍͜ͱ͕·͍͠ • ίϛοτͷվม͕ՄೳͳͷͰɺଞͷϢʔβʔ ͕༻͢Δ߹
Pull Request ͰϨϏϡʔΛ ड͚Δίϛοτͷ༰Λมߋͯ͠͠·͏
git rebase Λ͏Ϟνϕʔγϣϯ ͱ͍ಓ • ޙ͔ΒίϛοτཤྺΛݟͨ࣌ʹԿΛ͍ͯ͠Δ͔ ͔Γ͍ͨ͘͢͠ • ϩʔΧϧϒϥϯνʹϚʔδίϛοτΛੜͤͣ ʹɺϦϞʔτϒϥϯνͷมߋΛऔΓࠐΈ͍ͨ࣌
• ίϛοτͷॱ൪Λม͍͑ͨͱ͖ • ίϛοτΛ·ͱΊ͍ͨͱ͖
git pull
ϦϞʔτϒϥϯνͱ ্ྲྀϒϥϯν ϩʔΧϧϦϙδτϦ ϦϞʔτϦϙδτϦ NBJO UBTL PSJHJONBJO PSJHJOUBTL NBJO UBTL
ϦϞʔτϒϥϯν origin #"ͷ্ྲྀϒϥϯν "#ͷϦϞʔτϒϥϯν B B A A ϩʔΧϧ ϒϥϯν
git pull ͷڍಈ • git pull = git fetch +
git merge • git fetch : ϦϞʔτϦϙδτϦͷมߋΛ ϦϞʔτϒϥϯνʹऔΓࠐΉ • git pull ίϚϯυͰҾΛলུͯ͠ಈ࡞͢Δ ͷɺ্ྲྀϒϥϯν͕ઃఆ͞Ε͍ͯΔͨΊ
git pull ͷڍಈ ϩʔΧϧϦϙδτϦ ϦϞʔτϦϙδτϦ NBJO UBTL PSJHJONBJO PSJHJOUBTL NBJO
UBTL ϦϞʔτϒϥϯν origin ϩʔΧϧ ϒϥϯν git merge git fetch git pull
git pull -r (--rebase) • git merge ͷڍಈΛ git rebase
ʹม͑Δ͜ͱ͕Ͱ͖Δ • git pull ࣌ʹൃੜՄೳੑͷ͋ΔϚʔδίϛοτΛ ࡞ͨ͘͠ͳ͍߹ίϛοτϩάΛ៉ྷʹ ͠ͳ͕ΒมߋΛऔΓࠐΈ͍ͨ߹ʹ༻͢Δ • git rebase ͷίϛοτվมͷՄೳੑ͕͋ΔͷͰɺ push લͳͲͷར༻ʹݶΔ΄͏͕ྑ͍
git pull -r ͷڍಈ ϩʔΧϧϦϙδτϦ ϦϞʔτϦϙδτϦ NBJO UBTL PSJHJONBJO PSJHJOUBTL
NBJO UBTL ϦϞʔτϒϥϯν origin ϩʔΧϧ ϒϥϯν git rebase git fetch git pull -r
DEMO
·ͱΊ
·ͱΊ • git rebase Λ͏ͱίϛοτཤྺ͕៉ྷʹͳΔ • ίϛοτվมΛ͏ͷͰ༻๏༻ྔΛक͍ͬͯ ·͠ΐ͏