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
9
13k
Simplicity on Rails -- RDB, REST and Ruby
moro
14
17k
ちょうどよい 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.9k
フォームオブジェクトとの向き合い方/Grow Form Objects up
moro
1
1.9k
チームによるいきいきとしたソフトウェア開発/an-alive-team-grows-software
moro
3
3.3k
Web-E2E-Testing-from-Ruby
moro
5
510
Joyful user foundation restructuring with Ruby
moro
9
19k
Other Decks in Programming
See All in Programming
TypeScript でバックもやるって実際どう? 実運用で困ったこと3選
yuichiro_serita
17
7.7k
eBPF Deep Dive: Architecture and Safety Mechanisms
takehaya
12
1.4k
ソフトウェアの振る舞いに着目し 複雑な要件の開発に立ち向かう
rickyban
0
880
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
250
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
900
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
220
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
260
HTTP compression in PHP and Symfony apps
dunglas
2
1.6k
競技プログラミングで 基礎体力を身につけよう / You can get basic skills through competitive programming
mdstoy
0
170
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
170
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
210
useSyncExternalStoreを使いまくる
ssssota
5
920
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
How STYLIGHT went responsive
nonsquared
95
5.2k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
How GitHub (no longer) Works
holman
310
140k
The Language of Interfaces
destraynor
154
24k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Why Our Code Smells
bkeepers
PRO
335
57k
Building Your Own Lightsaber
phodgson
103
6.1k
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Λཧ ղ͢Δ伴ͩɻ͋ͳͨͷ৺͕ίϛοτͷ τϙϩδΛͨͩड༰͢Δ࣌ɺϒϥϯ νɺλάɺϩʔΧϧˍϦϞʔτϦϙδ τϦͷࠞཚஔ͖ڈΓʹ͞Εɺ͋ͳ ͨӥஐ͋Δષɾϒϥϯνϯάͷฏ ͱୡͨ͠ͷΛΔͩΖ͏ɻ