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
git入門
Search
uzimaru0000
September 26, 2020
Technology
1
340
git入門
Zli × エキサイト 合同LT
https://zli.connpass.com/event/188279/
uzimaru0000
September 26, 2020
Tweet
Share
More Decks by uzimaru0000
See All by uzimaru0000
OGPを使いたい
uzimaru0000
0
170
Webフロントエンド入門
uzimaru0000
1
440
WebフロントエンジニアはOSの夢を見る
uzimaru0000
0
360
BrainFuckをつくった
uzimaru0000
0
510
Elmで作るCLI
uzimaru0000
0
130
Blogを作った話 -Zli x DeNA-
uzimaru0000
1
190
Compression Vue App
uzimaru0000
0
130
好きなライブラリ_OSS
uzimaru0000
0
230
Other Decks in Technology
See All in Technology
Azure AI Foundryでマルチエージェントワークフロー
seosoft
0
180
Node-REDのFunctionノードでMCPサーバーの実装を試してみた / Node-RED × MCP 勉強会 vol.1
you
PRO
0
110
rubygem開発で鍛える設計力
joker1007
2
190
“社内”だけで完結していた私が、AWS Community Builder になるまで
nagisa53
1
370
SalesforceArchitectGroupOsaka#20_CNX'25_Report
atomica7sei
0
150
ハノーバーメッセ2025座談会.pdf
iotcomjpadmin
0
160
250627 関西Ruby会議08 前夜祭 RejectKaigi「DJ on Ruby Ver.0.1」
msykd
PRO
2
250
「Chatwork」の認証基盤の移行とログ活用によるプロダクト改善
kubell_hr
1
140
AIのAIによるAIのための出力評価と改善
chocoyama
2
540
初めてのAzure FunctionsをClaude Codeで作ってみた / My first Azure Functions using Claude Code
hideakiaoyagi
1
210
Microsoft Build 2025 技術/製品動向 for Microsoft Startup Tech Community
torumakabe
2
260
GitHub Copilot の概要
tomokusaba
1
130
Featured
See All Featured
A better future with KSS
kneath
239
17k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
How to Ace a Technical Interview
jacobian
277
23k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.8k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Building an army of robots
kneath
306
45k
Being A Developer After 40
akosma
90
590k
Visualization
eitanlees
146
16k
How to train your dragon (web standard)
notwaldorf
92
6.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.5k
Transcript
git入門 うじまる
自己紹介 - B4 - うじまる - Webフロントエンド - TypeScript -
Elm - 最近Rustをやってます。 - Twitter - @uzimaru0000 - GitHub - @uzimaru0000
みなさんgitは使ってますか?
使ってますね
ありがとうございました!
終わりません♂
gitの仕組み分かりますか?
gitの仕組み入門 うじまる
もくじ - gitって? - gitの仕組み - `git add` を使わないで `git
add` をしてみる
gitって?
gitって? Git(ギット[2][3][4])は、プログラムのソースコードなどの変更履歴を記録・追跡するための分散型バージョン管理システムである。 (wikipediaより) - 分散型バージョン管理システム - Linux カーネルの開発者のリーナスさんが作ったシステム
gitって? Q. 情報はどこに保存されてる? A. `.git` ディレクトリ以下
gitって? - HEAD - `git push origin HEAD` とかで参照される
- index - いわゆるstaging - objects/ - gitのobjectの保存先 - refs/ - branchとかtagsの保存先
gitって? - HEAD - `git push origin HEAD` とかで参照される
- index - いわゆるstaging - objects/ - gitのobjectの保存先 - refs/ - branchとかtagsの保存先
git-object - gitは3種類のobjectによって構成されている - commit - tree - blob -
それぞれ、commit・ディレクトリ・ファイルに対応している - sha1で固有のIDが割り当てられる - zlibで圧縮されている
git-object フォーマットは以下のような感じ - このobjectのtype - bodyのbytes数 - body(objectのtypeによって中身は変わる)
git-object - commit - 親のcommit, ルートのtree, commitをした人などの情報が記録されている - tree
- ディレクトリの情報が記録されている - 1つ以上のtreeやblobを持っている - blob - ファイルの情報が記録されている - `git add` した時点のファイルのスナップショット ※ git は 差分 ではなく ファイルの中身すべて を保存している
git-object sha1の作られ方 - objectの中身を使う
git-object 結果が違う・・・・ 原因:object fileはzlibで圧縮されている
git-object `zlib_decompress` を使ってファイルを解凍 同じ結果になった!!
git-object - sha1の値がそのままpathになる - 上2桁がディレクトリで残りがファイル名 コンテンツからsha1が生成されるので 同じ内容のものは重複しない!
HEADとrefs/ - HEADには現在のHEADのpathが書いてる - .git/refs/heads/master が今のHEAD(ブランチ)
HEADとrefs/ - HEADの値を使って `refs/` の値を見てみる
gitの仕組み
git-objectの関係性
git-objectの関係性
git-objectの関係性
git addをしてみる
gitのコマンド - git add や git commit などのコマンド - これらは「磁器コマンド」と呼ばれる
- git cat-file や git hash-object などのコマンド - これらは「配管コマンド」と呼ばれる 配管コマンドを組み合わせれば、磁器コマンド相当のことができる!! (昔はそうしていたみたい)
git addをしてみる $ git hash-object - ファイルをblobにするためのコマンド - `-w` オプションをつけることで保存もしてくれる
$ git update-index - indexをupdateしてくれる - optionがちょっと多い
git addをしてみる
DEMO
まとめ - git の仕組みは意外とシンプル - git-objectのパースと配管コマンドの実装が出来たらgitは作れる
None
ありがとうございました!