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.5k
Ruby クラスは「製造機」/fjordbootcamp-200627
masuyama13
2
1.5k
Other Decks in Programming
See All in Programming
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
280
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
初めてDefinitelyTypedにPRを出した話
syumai
0
400
Quine, Polyglot, 良いコード
qnighy
4
640
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Embracing the Ebb and Flow
colly
84
4.5k
Building an army of robots
kneath
302
43k
A better future with KSS
kneath
238
17k
Code Review Best Practice
trishagee
64
17k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Speed Design
sergeychernyshev
24
610
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/ ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠