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
9.5k
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
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
490
Joyful user foundation restructuring with Ruby
moro
9
19k
Other Decks in Programming
See All in Programming
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
4
2k
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
0
160
Amazon Qを使ってIaCを触ろう!
maruto
0
370
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
130
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.3k
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
210
EventSourcingの理想と現実
wenas
6
2.2k
Jakarta EE meets AI
ivargrimstad
0
100
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
17
4.3k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
350
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
790
Tuning GraphQL on Rails
pyama86
2
1.2k
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
33
2.9k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
2k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Producing Creativity
orderedlist
PRO
341
39k
Why Our Code Smells
bkeepers
PRO
334
57k
RailsConf 2023
tenderlove
29
890
How GitHub (no longer) Works
holman
310
140k
Ruby is Unlike a Banana
tanoku
96
11k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
15
2k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
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Λཧ ղ͢Δ伴ͩɻ͋ͳͨͷ৺͕ίϛοτͷ τϙϩδΛͨͩड༰͢Δ࣌ɺϒϥϯ νɺλάɺϩʔΧϧˍϦϞʔτϦϙδ τϦͷࠞཚஔ͖ڈΓʹ͞Εɺ͋ͳ ͨӥஐ͋Δષɾϒϥϯνϯάͷฏ ͱୡͨ͠ͷΛΔͩΖ͏ɻ