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
56
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
48
GitHubで始めるdotfiles管理 / Getting started with GitHub for dotfiles management
takasp
0
35
第三回 Datadog 共有会 / Datadog Sharing 3rd
takasp
0
73
第二回 Datadog 共有会 / Datadog Sharing 2nd
takasp
0
72
Datadog 共有会 / Datadog Sharing
takasp
1
50
Git ハンズオン Part 1 / Git Handson Part 1
takasp
0
57
Docker ハンズオン 基礎編2 / Docker Handson Basic 2
takasp
1
88
Docker ハンズオン 基礎編1 / Docker Handson Basic 1
takasp
1
170
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
693
190k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
360
The World Runs on Bad Software
bkeepers
PRO
66
11k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Into the Great Unknown - MozCon
thekraken
34
1.6k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
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 Λ͏ͱίϛοτཤྺ͕៉ྷʹͳΔ • ίϛοτվมΛ͏ͷͰ༻๏༻ྔΛक͍ͬͯ ·͠ΐ͏