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
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
280
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
3.9k
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
370
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.1k
事業成長を爆速で進めてきたプロダクトエンジニアたちの成功談・失敗談
nealle
3
1.3k
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
110
命名をリントする
chiroruxx
1
260
Java 23の概要とJava Web Frameworkの現状 / Java 23 and Java web framework
kishida
2
390
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
0
240
Amazon Aurora Serverless v2のアプデと、Amazon Aurora PostgreSQL Limitless DatabaseのGAについて
satoshi256kbyte
0
110
14 Years of iOS: Lessons and Key Points
seyfoyun
1
740
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
850
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
222
9k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
270
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.8k
Automating Front-end Workflow
addyosmani
1366
200k
Side Projects
sachag
452
42k
We Have a Design System, Now What?
morganepeng
51
7.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Become a Pro
speakerdeck
PRO
25
5k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
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Λཧ ղ͢Δ伴ͩɻ͋ͳͨͷ৺͕ίϛοτͷ τϙϩδΛͨͩड༰͢Δ࣌ɺϒϥϯ νɺλάɺϩʔΧϧˍϦϞʔτϦϙδ τϦͷࠞཚஔ͖ڈΓʹ͞Εɺ͋ͳ ͨӥஐ͋Δષɾϒϥϯνϯάͷฏ ͱୡͨ͠ͷΛΔͩΖ͏ɻ