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
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
510
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
320
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
150
イベント駆動で成長して委員会
happymana
1
300
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Amazon Qを使ってIaCを触ろう!
maruto
0
390
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
4
860
距離関数を極める! / SESSIONS 2024
gam0022
0
240
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.8k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9k
Designing the Hi-DPI Web
ddemaree
280
34k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Writing Fast Ruby
sferik
627
61k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Being A Developer After 40
akosma
86
590k
Code Reviewing Like a Champion
maltzj
520
39k
Making Projects Easy
brettharned
115
5.9k
Music & Morning Musume
bryan
46
6.2k
Happy Clients
brianwarren
98
6.7k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
830
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/ ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠