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
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
790
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
開発効率向上のためのリファクタリングの一歩目の選択肢 ~コード分割~ / JJUG CCC 2024 Fall
ryounasso
0
420
デプロイを任されたので、教わった通りにデプロイしたら障害になった件 ~俺のやらかしを越えてゆけ~
techouse
53
34k
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
300
約9000個の自動テストの 時間を50分->10分に短縮 Flakyテストを1%以下に抑えた話
hatsu38
24
12k
リリース8年目のサービスの1800個のERBファイルをViewComponentに移行した方法とその結果
katty0324
5
4.2k
Hotwire or React? ~Reactの録画機能をHotwireに置き換えて得られた知見~ / hotwire_or_react
harunatsujita
8
5.1k
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
110
カスタムしながら理解するGraphQL Connection
yanagii
1
1.5k
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1.1k
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
160
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Teambox: Starting and Learning
jrom
133
8.8k
A Philosophy of Restraint
colly
203
16k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
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Λཧ ղ͢Δ伴ͩɻ͋ͳͨͷ৺͕ίϛοτͷ τϙϩδΛͨͩड༰͢Δ࣌ɺϒϥϯ νɺλάɺϩʔΧϧˍϦϞʔτϦϙδ τϦͷࠞཚஔ͖ڈΓʹ͞Εɺ͋ͳ ͨӥஐ͋Δષɾϒϥϯνϯάͷฏ ͱୡͨ͠ͷΛΔͩΖ͏ɻ