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
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
3
300
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
410
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
270
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
140
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
testcontainers のススメ
sgash708
1
120
Haze - Real time background blurring
chrisbanes
1
520
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
5
740
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
490
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
940
Recoilを剥がしている話
kirik
5
6.8k
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Building Your Own Lightsaber
phodgson
103
6.1k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Mobile First: as difficult as doing things right
swwweet
222
9k
Rails Girls Zürich Keynote
gr2m
94
13k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Unsuck your backbone
ammeep
669
57k
Why Our Code Smells
bkeepers
PRO
335
57k
Scaling GitHub
holman
458
140k
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/ ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠