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
My mental model about Git
Search
MOROHASHI Kyosuke
November 15, 2011
Programming
7
1.7k
My mental model about Git
Talk for newbie programmers in Eiwa System Management, Inc.
MOROHASHI Kyosuke
November 15, 2011
Tweet
Share
More Decks by MOROHASHI Kyosuke
See All by MOROHASHI Kyosuke
Identifying User Idenity
moro
6
10k
Simplicity on Rails -- RDB, REST and Ruby
moro
14
16k
ちょうどよい Rails E2E テスト/enough-good-rails-e2e-test
moro
5
2.3k
フレームワークを作らない方法/How NOT to build frameworks
moro
4
1.1k
全体がいい感じになるために、私たちRailsをホームにするWeb技術者ができること/let-our-whole-system-grow
moro
2
1.8k
フォームオブジェクトとの向き合い方/Grow Form Objects up
moro
1
1.9k
チームによるいきいきとしたソフトウェア開発/an-alive-team-grows-software
moro
3
3.3k
Web-E2E-Testing-from-Ruby
moro
5
500
Joyful user foundation restructuring with Ruby
moro
9
19k
Other Decks in Programming
See All in Programming
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
940
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
150
Jakarta EE meets AI
ivargrimstad
0
620
Better Code Design in PHP
afilina
PRO
0
130
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.7k
C++でシェーダを書く
fadis
6
4.1k
RubyLSPのマルチバイト文字対応
notfounds
0
120
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
240
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Thoughts on Productivity
jonyablonski
67
4.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
Music & Morning Musume
bryan
46
6.2k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Site-Speed That Sticks
csswizardry
0
29
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Practical Orchestrator
shlominoach
186
10k
Transcript
Gitʹ͍ͭͯߟ͑Δͱ͖ʹ ͕ߟ͑Δ͜ͱ CC 3.0 BY-SA ESM > SP > AGG
ॾڮګհ
ࠓͷຊ͡Όͳ͍͜ͱ •ϒϥϯνઓུ •mergeͱrebaseͷҧ͍ •Subversionͱ͔CVSͱ͔ͱͷൺֱ •όʔδϣϯཧͱ
ΰʔϧ
Git ΛϘτϜΞοϓ͔Βཧղ͢Δ http://keijinsonyaban.blogspot.com/2011/05/git.html ίϛοτΛཧղ͢Δ͜ͱ(JUΛཧ ղ͢Δ伴ͩɻ͋ͳͨͷ৺͕ίϛοτͷ τϙϩδΛͨͩड༰͢Δ࣌ɺϒϥϯ νɺλάɺϩʔΧϧˍϦϞʔτϦϙδ τϦͷࠞཚஔ͖ڈΓʹ͞Εɺ͋ͳ ͨӥஐ͋Δષɾϒϥϯνϯάͷฏ ͱୡͨ͠ͷΛΔͩΖ͏ɻ
ཁ
Git ΛϘτϜΞοϓ͔Βཧղ͢Δ http://keijinsonyaban.blogspot.com/2011/05/git.html ͭ·Γ(JUͰɺੈքγϯϓϧͳ ίϛοτΦϒδΣΫτͷू߹Ͱ͋Γɺ ͦΕͧΕͷίϛοτΦϒδΣΫτ͕ଞ ͷUSFFCMPCΛࢀর͢ΔUSFFΛ อ࣋͠ɺCMPCʹσʔλ͕อ͞Ε ͍ͯΔɻ͜ΕΑΓෳࡶͳશͯɺ୯ ʹ༻ޠతͳ০Γʹ͗͢ͳ͍ɻ
imagine "File System" / Users moro hello.txt foo README lib
foo.rb bin foo directory file
/ Users moro hello.txt foo README lib foo.rb bin foo
/ Users moro hello.txt foo README lib foo.rb bin foo v1 v2
/ Users moro hello.txt foo README lib foo.rb bin foo
/ Users moro hello.txt foo README lib foo.rb bin foo v1 v2 / Users moro hello.txt foo README lib foo.rb bin foo v3
•σΟϨΫτϦ •ͿΒԼ͕͍ͬͯΔϑΝΠϧσΟϨΫ τϦͷใΛอ࣋͢Δ •ϑΝΠϧ •தʹ"࣮"Ͱ͋ΔσʔλΛอ࣋͢Δ
•commit •tree •blob
• commit • tree • ͿΒԼ͕͍ͬͯΔblobtreeͷใΛ อ࣋͢Δ • blob •
தʹ"࣮"Ͱ͋ΔσʔλΛอ࣋͢Δ
/ Users moro hello.txt foo README lib foo.rb bin foo
/ Users moro hello.txt foo README lib foo.rb bin foo v1 v2 தͷblobtree͕มΘΔͱɺͦͷtreeมΘΔ
/ Users moro hello.txt foo README lib foo.rb bin foo
/ Users moro hello.txt foo README lib foo.rb bin foo v1 v2 தͷblobtree͕มΘΔͱɺͦͷtreeมΘΔ ͱɺͦͷͷtreeมΘΔ
/ Users moro hello.txt foo README lib foo.rb bin foo
/ Users moro hello.txt foo README lib foo.rb bin foo v1 v2 / Users moro hello.txt foo README lib foo.rb bin foo v3
•tree ͕Θ͔Εؚ·ΕΔtreeͱblob͕ Θ͔Δ •ҙͷόʔδϣϯΛ෮ݩͰ͖Δ •ࠜͬ͜(root)ͷtree͕Θ͔ΕҰࣜ෮ ݩͰ͖Δ
$ git status commit a4d1f1bdc3822432bc94cf68d0bffb095264a004 Merge: 40e5867 b339846 Author: Kenichi
TAKAHASHI <
[email protected]
> Date: 2011-11-08 17:49:09 -0800 Merge pull request #8 from esminc/tapp-grep-filter-gemfile filter Gemfile on tapp grep (thanks kakutani) $ git ls-tree HEAD 100644 blob 476fcf245ea98e5b53c1bab8e4649fded29deafb .gitignore 100644 blob 8ced21a16d6f7a27031f42b42ed50c58ccd0437b CHANGELOG.md 100644 blob 7ca6519299b1f11b9b40e6e47ff82ccb1318a9c6 Gemfile 100644 blob 3b2c28480b4333df5d64316fb185776f31a64aaa LICENSE 100644 blob bb91262ae86a22e7e943c2fef7d2ed6a3f5a3850 README.rdoc 100644 blob c702cfccca1ced72a75bfd5b26e5e91d71c40b9f Rakefile 040000 tree a7b194b502ea1c0a1c351c057bc79c350b2ea9c7 bin 040000 tree a58e4002624c16f977f4a9bdcb3dbb7bdfdae407 lib 100644 blob 659747ab02ba3d057cb61df2c9ea4dc49e84b182 tapp.gemspec $ git ls-tree HEAD:lib 100644 blob 831db79304eeb1f41920b2c41074c4c9a8980ef9 tapp.rb 040000 tree 958acbdfa5bbb4cb6b42c2020d49e9934b1c69b8 tapp $ git ls-tree HEAD:lib/tapp 100644 blob fca06de5860379429be9e81b7efd087387f26f6b command.rb 100644 blob baaf6dd99cd986f245152ec19b315f0d13d097ad version.rb
rootͳtreeͷ Έ͚͔ͭͨ
• commit • ͍ͭɾ୭͕ɾͲͷcommitͷࢠͱͯ͠ • ࠜͬ͜ͷtree(ʹͿΒԼ͕ΔtreeͱblobҰࣜ) Λ࡞͔ͬͨ • tree •
blob
$ git cat-file commit HEAD tree 616ecd5707ab2e0c2902ce75da7040a0bea30ed4 parent 40e58671aed9266f55fc4a93b746caf30bc13fc4 parent
b339846bd6e592f6d5d1911e4a9a9332f0b07255 author Kenichi TAKAHASHI <
[email protected]
> 1320803349 -0800 committer Kenichi TAKAHASHI <
[email protected]
> 1320803349 -0800 Merge pull request #8 from esminc/tapp-grep-filter-gemfile filter Gemfile on tapp grep (thanks kakutani) $ git ls-tree 616ecd5707ab2 100644 blob 476fcf245ea98e5b53c1bab8e4649fded29deafb .gitignore 100644 blob 8ced21a16d6f7a27031f42b42ed50c58ccd0437b CHANGELOG.md 100644 blob 7ca6519299b1f11b9b40e6e47ff82ccb1318a9c6 Gemfile 100644 blob 3b2c28480b4333df5d64316fb185776f31a64aaa LICENSE 100644 blob bb91262ae86a22e7e943c2fef7d2ed6a3f5a3850 README.rdoc 100644 blob c702cfccca1ced72a75bfd5b26e5e91d71c40b9f Rakefile 040000 tree a7b194b502ea1c0a1c351c057bc79c350b2ea9c7 bin 040000 tree a58e4002624c16f977f4a9bdcb3dbb7bdfdae407 lib 100644 blob 659747ab02ba3d057cb61df2c9ea4dc49e84b182 tapp.gemspec
$ git status commit a4d1f1bdc3822432bc94cf68d0bffb095264a004 Merge: 40e5867 b339846 Author: Kenichi
TAKAHASHI <
[email protected]
> Date: 2011-11-08 17:49:09 -0800 Merge pull request #8 from esminc/tapp-grep-filter-gemfile filter Gemfile on tapp grep (thanks kakutani) $ git ls-tree HEAD 100644 blob 476fcf245ea98e5b53c1bab8e4649fded29deafb .gitignore 100644 blob 8ced21a16d6f7a27031f42b42ed50c58ccd0437b CHANGELOG.md 100644 blob 7ca6519299b1f11b9b40e6e47ff82ccb1318a9c6 Gemfile 100644 blob 3b2c28480b4333df5d64316fb185776f31a64aaa LICENSE 100644 blob bb91262ae86a22e7e943c2fef7d2ed6a3f5a3850 README.rdoc 100644 blob c702cfccca1ced72a75bfd5b26e5e91d71c40b9f Rakefile 040000 tree a7b194b502ea1c0a1c351c057bc79c350b2ea9c7 bin 040000 tree a58e4002624c16f977f4a9bdcb3dbb7bdfdae407 lib 100644 blob 659747ab02ba3d057cb61df2c9ea4dc49e84b182 tapp.gemspec $ git ls-tree HEAD:lib 100644 blob 831db79304eeb1f41920b2c41074c4c9a8980ef9 tapp.rb 040000 tree 958acbdfa5bbb4cb6b42c2020d49e9934b1c69b8 tapp $ git ls-tree HEAD:lib/tapp 100644 blob fca06de5860379429be9e81b7efd087387f26f6b command.rb 100644 blob baaf6dd99cd986f245152ec19b315f0d13d097ad version.rb
/ Users moro hello.txt foo README lib foo.rb bin foo
/ Users moro hello.txt foo README lib foo.rb bin foo v1 v2 / Users moro hello.txt foo README lib foo.rb bin foo v3 tree: abc efgh5678 tree: def tree: xyz hello world! v1ͷࢠͱͯ͠ɺ2011-11-11ʹͰ͖ͨΑɻ தtree: def͔ΒͨͲΕΔΑ v2ͷࢠͱͯ͠ɺ2011-11-12ʹͰ͖ͨΑɻ தtree: xyz͔ΒͨͲΕΔΑ
•commit͕Θ͔Εroot tree͕Θ͔Δ •root tree͕Θ͔ΕͿΒԼ͕Δtreeͱ blob͕Θ͔Δ •treeͱblob͕Θ͔ΕϑΝΠϧͱσΟ ϨΫτϦͱͯ͠औΓग़ͤΔ Ͳ͏ͯ͠commit͕େࣄ͔
•commit͕Θ͔Εͷcommit͕Θ ͔Δ •ͷcommit͕Θ͔Εɺͦͷ࣌ͷ ϑΝΠϧ(blob)σΟϨΫτϦ(tree)͕ Θ͔Δ •ཤྺΛཧͰ͖Δ! Ͳ͏ͯ͠commit͕େࣄ͔
Git ΛϘτϜΞοϓ͔Βཧղ͢Δ http://keijinsonyaban.blogspot.com/2011/05/git.html
Git ΛϘτϜΞοϓ͔Βཧղ͢Δ http://keijinsonyaban.blogspot.com/2011/05/git.html ͭ·Γ(JUͰɺੈքγϯϓϧͳ ίϛοτΦϒδΣΫτͷू߹Ͱ͋Γɺ ͦΕͧΕͷίϛοτΦϒδΣΫτ͕ଞ ͷUSFFCMPCΛࢀর͢ΔUSFFΛ อ࣋͠ɺCMPCʹσʔλ͕อ͞Ε ͍ͯΔɻ͜ΕΑΓෳࡶͳશͯɺ୯ ʹ༻ޠతͳ০Γʹ͗͢ͳ͍
commitΛ Ί͙Δݥ
•ͳʹ͞ͳ͍ •git log •҉ͰݱϒϥϯνͷHEAD
•HEAD •git log HEAD •ݱϒϥϯνͷHEAD
•commitͷsha1 •git log b33984 •શ෦Ͱͳ͍͍ͯ͘
•ϒϥϯνͱ͔ •tagͱ͔
•ϒϥϯνͬͯͳʹ? •tag? •commitͷผ໊
•λά •git log rel-2011-01 •λά͕ࢦ͢ίϛοτ
•ϒϥϯνͬͯͳʹ? •commitͷੵΈॏͳΓ͕৳ͼ͍ͯ͘ํ Λࢦ͢ͷ •tag? Ҏޙɺσʔλͱͯ͠ͷcommit objectcommitɺgit commit͢Δ ͜ͱίϛοτͱݺͼ·͢
•git commitͰίϛοτ͢Δͱ •commit ΦϒδΣΫτ͕Ͱ͖Δ •ϒϥϯνͷઌ಄(HEAD) ͕ͦͷcommitΦϒ δΣΫτΛࢦ͢Α͏ʹॻ͖มΘΔ
•git checkout <ϒϥϯν>͢Δͱ •ϒϥϯνͷHEAD͕ࢦ͢commit͕ ࢀর͍ͯ͠Δtree͔Βඥ͘ιʔε ҰࣜΛworking treeʹల։͢Δɻ
•ϒϥϯνͬͯͳʹ? •commitͷੵΈॏͳΓ͕৳ͼ͍ͯ͘ํ Λࢦ͢ͷ •ͦͯ͠ଟ͘ͷ߹ɺͷͼ͖ͯͨઌ಄ͭ ·ΓHEADΛࢦ͢ •tag?
•ϒϥϯν໊ •git log cli •ϩʔΧϧϒϥϯνcliͷHEAD
•͍֮͑ͯ·͔͢: ͳʹ͞ͳ͍ •git log •҉ͰݱϒϥϯνͷHEAD
•ϦϞʔτϒϥϯν໊ •git log origin/cli •ϦϞʔτϦϙδτϦoriginͷ cliϒϥϯνͷHEAD
•ϦϞʔτϒϥϯν໊ •git log origin/cli •ϦϞʔτϦϙδτϦoriginͷ cliϒϥϯνͷHEAD
remote ϦϞʔτ
•ԕ͘ʹ͋Δrepoʹ໊લΛ͚ͭͨͷ •
[email protected]
:esminc/tapp.git ͱ͔͍ͭࢦఆͨ͘͠ͳ͍͠Ͷ •ผͷrepoʹؚ·ΕΔϒϥϯνΛ remotes/#{໊લ} ҎԼʹ͍࣋ͬͯΔ •ࢀরͨ͠ΓɺϩʔΧϧϒϥϯνʹ checkoutͨ͠Γɺpushͨ͠ΓͰ͖Δ
•ϦϞʔτ(ͷrepoʹؔ࿈͍ͨͪΐͬͱ ಛघͳ)ϒϥϯν •checkoutͰ͖ͳ͍ (detachedʹͳΔɻڪΖ͠…) •git fetch #{repo໊}ͰϦϞʔτͷ commitΛऔಘͰ͖Δ
push ϓογϡ
•खݩͷcommit(ͨͪɻؚઌ)Λ remoteʹૹΓࠐΉ •git push #{repo໊} #{commit} •commitͷࢦఆํ๏લड़ͷͱ͓Γ
•git log master..origin/master • ϩʔΧϧʹͳ͍ɺ୭͔͕࡞ͬͨίϛοτ • ࠨʹͳͯ͘ӈʹ͋Δcommit
•blob(ϑΝΠϧ) •git log origin/master...master:\ path/to/file •origin/masterʹͳͯ͘masterʹ͋ Δpath/to/fileͷมߋΛݟΔ
ଓ͖ggr "git tree-ish"
Git ΛϘτϜΞοϓ͔Βཧղ͢Δ http://keijinsonyaban.blogspot.com/2011/05/git.html ͭ·Γ(JUͰɺੈքγϯϓϧͳ ίϛοτΦϒδΣΫτͷू߹Ͱ͋Γɺ ͦΕͧΕͷίϛοτΦϒδΣΫτ͕ଞ ͷUSFFCMPCΛࢀর͢ΔUSFFΛ อ࣋͠ɺCMPCʹσʔλ͕อ͞Ε ͍ͯΔɻ͜ΕΑΓෳࡶͳશͯɺ୯ ʹ༻ޠతͳ০Γʹ͗͢ͳ͍ɻ
Git ΛϘτϜΞοϓ͔Βཧղ͢Δ http://keijinsonyaban.blogspot.com/2011/05/git.html ίϛοτΛཧղ͢Δ͜ͱ(JUΛཧ ղ͢Δ伴ͩɻ͋ͳͨͷ৺͕ίϛοτͷ τϙϩδΛͨͩड༰͢Δ࣌ɺϒϥϯ νɺλάɺϩʔΧϧˍϦϞʔτϦϙδ τϦͷࠞཚஔ͖ڈΓʹ͞Εɺ͋ͳ ͨӥஐ͋Δષɾϒϥϯνϯάͷฏ ͱୡͨ͠ͷΛΔͩΖ͏ɻ