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
54
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
71
第二回 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
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
BBQ
matthewcrist
85
9.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Site-Speed That Sticks
csswizardry
0
28
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Making Projects Easy
brettharned
115
5.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
RailsConf 2023
tenderlove
29
900
Why Our Code Smells
bkeepers
PRO
334
57k
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 Λ͏ͱίϛοτཤྺ͕៉ྷʹͳΔ • ίϛοτվมΛ͏ͷͰ༻๏༻ྔΛक͍ͬͯ ·͠ΐ͏