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
32
第三回 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
The Power of CSS Pseudo Elements
geoffreycrofte
71
5.3k
Ruby is Unlike a Banana
tanoku
96
11k
Building Applications with DynamoDB
mza
90
6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
38
9.2k
Side Projects
sachag
451
42k
Mobile First: as difficult as doing things right
swwweet
221
8.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
36
2.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
43
2k
Building a Scalable Design System with Sketch
lauravandoore
459
32k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
26
3.9k
Clear Off the Table
cherdarchuk
91
320k
No one is an island. Learnings from fostering a developers community.
thoeni
18
2.9k
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 Λ͏ͱίϛοτཤྺ͕៉ྷʹͳΔ • ίϛοτվมΛ͏ͷͰ༻๏༻ྔΛक͍ͬͯ ·͠ΐ͏