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
110
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
72
第二回 Datadog 共有会 / Datadog Sharing 2nd
takasp
0
72
Datadog 共有会 / Datadog Sharing
takasp
1
50
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 Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Optimizing for Happiness
mojombo
376
70k
Statistics for Hackers
jakevdp
796
220k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
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 Λ͏ͱίϛοτཤྺ͕៉ྷʹͳΔ • ίϛοτվมΛ͏ͷͰ༻๏༻ྔΛक͍ͬͯ ·͠ΐ͏