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.7k
ペアプロ開発をスムーズに進めるための Tips/pair-programming-tips-20221009
masuyama13
1
1.4k
Ruby クラスは「製造機」/fjordbootcamp-200627
masuyama13
2
1.5k
Other Decks in Programming
See All in Programming
Outline View in SwiftUI
1024jp
1
280
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.3k
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.1k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
240
WEBエンジニア向けAI活用入門
sutetotanuki
0
330
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
480
Quine, Polyglot, 良いコード
qnighy
4
620
Realtime API 入門
riofujimon
0
140
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
280
EventSourcingの理想と現実
wenas
6
2.2k
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
510
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
0
130
Featured
See All Featured
Navigating Team Friction
lara
183
14k
Measuring & Analyzing Core Web Vitals
bluesmoon
2
75
Done Done
chrislema
181
16k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
How to Ace a Technical Interview
jacobian
276
23k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
Code Reviewing Like a Champion
maltzj
520
39k
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/ ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠