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-reset-200822
Search
masuyama13
August 22, 2020
Programming
0
2k
今度こそ理解する/git-reset-200822
masuyama13
August 22, 2020
Tweet
Share
More Decks by masuyama13
See All by masuyama13
ペアプロしようぜ 〜3人で登壇!? 楽しくて速いペアプロ/モブプロ開発〜/pair-mob-programming-kaigi-on-rails-2023
masuyama13
2
3.9k
ペアプロ開発をスムーズに進めるための Tips/pair-programming-tips-20221009
masuyama13
1
1.5k
Ruby クラスは「製造機」/fjordbootcamp-200627
masuyama13
2
1.5k
Other Decks in Programming
See All in Programming
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
460
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
CSC509 Lecture 14
javiergs
PRO
0
140
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
CSC305 Lecture 26
javiergs
PRO
0
140
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
710
Beyond ORM
77web
3
380
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
14 Years of iOS: Lessons and Key Points
seyfoyun
1
770
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
930
Featured
See All Featured
Unsuck your backbone
ammeep
669
57k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Typedesign – Prime Four
hannesfritz
40
2.4k
Into the Great Unknown - MozCon
thekraken
33
1.5k
We Have a Design System, Now What?
morganepeng
51
7.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Transcript
GIT RESET ࠓͦ͜ཧղ͢Δ 2020.08.22 FJORD BOOT CAMP LTձ
ൃද༰ GIT RESET ▸ git reset ͷಈ͖ ▸ ——softɺ——hardɺΦϓγϣϯলུʢ——mixedʣ ▸
HEAD ͱ ▸ ΠϯσοΫεͱ ࠓͦ͜ཧղ͢Δ
ࣗݾհ @masuyama13 ‣ ڈ12݄ʙ FjordBootCamp ࢀՃ ‣ ݱࡏͷϓϥΫςΟε ‣ ΦϒδΣΫτࢦϓϩάϥϛϯά
‣ ݩࢢॴ৬һʢࣄʣ ‣ ࣛࣇౡग़ https://masuyama13.hatenablog.com/ 4݄͔Βຖϒϩάߋ৽தʂ
ݱࡏͷ HEAD Λࢦఆ͞Εͨ ঢ়ଶʹ͢ɻ git reset Reset current HEAD to
the specified state
HEAD Λ͢ git reset —-softɹHEAD ͚ͩ͢ [—-mixed]ɹΠϯσοΫε͢ —-hardɹΠϯσοΫεͱϫʔΫπϦʔ͢
ϫʔΫπϦʔ git commit git add ϦϙδτϦ master A A A
touch A ϒϥϯνɿ ɾಛఆͷίϛοτΛࢦࣔ͢͠ϙΠϯλ ɾσϑΥϧτ͕ master ɾ࠷ॳͷίϛοτΛͨ࣌͠Ͱൃੜ ɾࢬ͔Εͷઌ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ ίϛοτ༧ఆͷͷΛొ͢Δॴ ϑΝΠϧฤूͳͲΛߦ͏࡞ۀॴ ʮίϛοτʯ ͕Ͱ͖Δ
ϦϙδτϦ ϫʔΫπϦʔ git commit git add HEAD master ɾݱࡏͷϒϥϯνΛࢦࣔ͢͠ϙΠϯλ ɾ࣍ͷίϛοτͷʹͳΔ
A A A ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ ίϛοτ༧ఆͷͷΛొ͢Δॴ ϑΝΠϧฤूͳͲΛߦ͏࡞ۀॴ ʮίϛοτʯ ͕Ͱ͖Δ
ϫʔΫπϦʔ ϦϙδτϦ git commit git add B B B A
A A HEAD master HEAD master A A A git commit git add ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
ϫʔΫπϦʔ ϦϙδτϦ git commit git add B B B A
A A HEAD master A A A git commit git add git commit git add B B B A A A C C C HEAD master ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
ϫʔΫπϦʔ ϦϙδτϦ git commit git add B B B A
A A A A A git commit git add git commit git add B B B A A A C C C HEAD master ͜ͷίϛοτऔΓফ͍ͨ͠ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
HEAD Λ͢ git reset —-softɹHEAD ͚ͩ͢ [—-mixed]ɹΠϯσοΫε͢ —-hardɹΠϯσοΫεͱϫʔΫπϦʔ͢
ϫʔΫπϦʔ ϦϙδτϦ git commit git add B B B A
A A A A A git commit git add git commit git add B B B A A A C C C HEAD master HEAD master औΓফ͢ git reset —-soft HEAD~ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
ϫʔΫπϦʔ ϦϙδτϦ git commit git add B B B A
A A A A A git commit git add git commit git add B B B A A A C C C HEAD master HEAD master औΓফ͢ git reset HEAD~ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
ϫʔΫπϦʔ ϦϙδτϦ git commit git add B B B A
A A A A A git commit git add git commit git add B B B A A A C C C HEAD master HEAD master औΓফ͢ git reset —-hard HEAD~ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
݁ߏ୯७ʁ
ΠϯσοΫε ͬͯԿʁ ʢεςʔδϯάΤϦΞʣ ίϛοτ͢Δલʹొ͠ͳ͍ͱ ͍͚ͳ͍ॴɾɾɾ ਖ਼ɺਂ͘ߟ͑ͨ͜ͱͳ͍
git commit ϫʔΫπϦʔ ϦϙδτϦ git add B B B A
A A A A git commit git add HEAD master HEAD master ͚ࠩͩ צҧ͍ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
git commit ϫʔΫπϦʔ ϦϙδτϦ git add B B B A
A A A A git commit git add git commit git add B B A A C C C HEAD master HEAD master ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
git commit ϫʔΫπϦʔ ϦϙδτϦ git add B B B A
A A A A git commit git add git commit git add B B A A C C C HEAD master HEAD master git reset —-soft HEAD~2 औΓফ͢ BΠϯσοΫε͔Β ফ͑ͪΌ͏!? ˞ޡΓͰ͢ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
ϫʔΫπϦʔ git commit git add ϦϙδτϦ HEAD master A A
A ࣍ͷίϛοτͷεφοϓγϣοτ εφοϓγϣοτɿ ؙ͝ͱίϐʔͨ͠ͷ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
ϫʔΫπϦʔ git add A A ࣍ͷίϛοτͷεφοϓγϣοτ εφοϓγϣοτɿ ؙ͝ͱίϐʔͨ͠ͷ git ls-files
ΠϯσοΫεʹ͋ΔϑΝΠϧͷϦετΛදࣔ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
ϫʔΫπϦʔ ϦϙδτϦ ʁʁʁ git add B A A A A
git commit git add git ls-files HEAD master ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ A B
git commit ϫʔΫπϦʔ ϦϙδτϦ git add B B B A
A A A A A git commit git add git commit git add B B B A A A C C C HEAD master HEAD master git reset —-soft HEAD~2 औΓফ͢ ΠϯσοΫε ʢεςʔδϯάΤϦΞʣ
ࠓͦ͜ཧղ͢Δ GIT RESET ·ͱΊ —-softɹHEAD ͚ͩ͢ [—-mixed]ɹHEAD ͱΠϯσοΫεΛ͢ —-hardɹHEAD ͱΠϯσοΫεͱϫʔΫπϦʔΛ͢
git reset ࠩͰͳ͘ɺίϛοτީิΛؙ͝ͱίϐʔͨ͠ͷ ͕อଘ͞Ε͍ͯΔ ΠϯσοΫεʢεςʔδϯάΤϦΞʣ
ࠓͦ͜ཧղ͢Δ GIT RESET ࢀߟࢿྉ ▸ Git ▸ https://git-scm.com/ ▸ αϧઌੜͷGitೖ
▸ https://backlog.com/ja/git-tutorial/ ▸ GitͷεςʔδϯάྖҬͷਖ਼ମΛ୳Δ | ϝϧΧϦΤϯδχΞϦϯά ▸ https://engineering.mercari.com/blog/entry/2017-04-06-171430/ ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠