<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Git on MeerStory</title><link>https://linux.meerstory.com/ja/categories/git/</link><description>Recent content in Git on MeerStory</description><generator>Hugo</generator><language>ja-jp</language><lastBuildDate>Sat, 14 Nov 2026 01:20:20 +0900</lastBuildDate><atom:link href="https://linux.meerstory.com/ja/categories/git/index.xml" rel="self" type="application/rss+xml"/><item><title>Ubuntuで探るGit内部構造：git-upload-packの仕組みと実践</title><link>https://linux.meerstory.com/ja/ubuntu/20261114_011930_306/</link><pubDate>Sat, 14 Nov 2026 01:20:20 +0900</pubDate><guid>https://linux.meerstory.com/ja/ubuntu/20261114_011930_306/</guid><description>&lt;h2 id="はじめに">はじめに&lt;/h2>
&lt;p>普段何気なく実行している &lt;code>git clone&lt;/code> や &lt;code>git fetch&lt;/code> の裏側では、リモートホスト側で対象オブジェクトをパッキングして送出する専用バイナリ &lt;code>git-upload-pack&lt;/code> が稼働しています。本稿ではこの低レイヤコマンドの責務と動作メカニズムを紐解きつつ、Ubuntuローカル上でGitデータ転送のやり取りを直接トレース・検証していきます。&lt;/p>
&lt;h2 id="1-検証環境のセットアップとgitパッケージの確認">1. 検証環境のセットアップとGitパッケージの確認&lt;/h2>
&lt;p>まずは検証のベースとなるパッケージインデックスを最新化し、GitツールチェーンをUbuntu環境へ導入します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261114_011930_306/captures/s01_c01_apt-get_update_-qq____apt-get_install_-y_git.png"
 alt="apt-get update -qq &amp;amp;&amp;amp; apt-get install -y git"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>インストール完了後、正しくバイナリが認識されているかを &lt;code>git --version&lt;/code> で確かめます。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261114_011930_306/captures/s01_c02_git_--version.png"
 alt="git &amp;ndash;version"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>Gitの内部通信を担う &lt;code>git-upload-pack&lt;/code> の配置先パスを &lt;code>which git-upload-pack&lt;/code> で特定しましょう。&lt;br>
このコマンドは、クライアントからの取得要求に対してサーバー側でオブジェクトを圧縮・パック転送するコアデーモン的役割を果たします。&lt;br>
⚙️ [押さえておきたい主要オプション]&lt;/p>
&lt;p>&lt;code>--strict&lt;/code> : リポジトリ内のオブジェクト整合性を厳密に検査し、破損や不正検知時に即座に転送を打ち切ります。&lt;br>
&lt;code>--timeout=&amp;lt;n&amp;gt;&lt;/code> : クライアントとの通信待機時間が指定した秒数を超過した場合にプロセスを強制終了します。&lt;br>
&lt;code>--stateless-rpc&lt;/code> : HTTP Smartプロトコルなどの環境下で、リクエスト単位のステートレス処理を行うモードに切り替えます。&lt;br>
&lt;code>--advertise-refs&lt;/code> : 保持しているブランチやタグの参照（ref）一覧および対応機能を提示し、即座に処理を終了します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261114_011930_306/captures/s01_c03_which_git-upload-pack.png"
 alt="which git-upload-pack"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;h2 id="2-実験用のベアリポジトリ構築と初期コミットの作成">2. 実験用のベアリポジトリ構築と初期コミットの作成&lt;/h2>
&lt;p>作業スペースを分離するため、専用ディレクトリ &lt;code>/tmp/git_lab&lt;/code> を新規作成してカレントディレクトリを切り替えます。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261114_011930_306/captures/s02_c01_mkdir_-p__tmp_git_lab____cd__tmp_git_lab.png"
 alt="mkdir -p /tmp/git_lab &amp;amp;&amp;amp; cd /tmp/git_lab"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p></description></item><item><title>Linux環境におけるgit-receive-pack入門：Gitプッシュの内部動作</title><link>https://linux.meerstory.com/ja/ubuntu/20261113_021039_303/</link><pubDate>Fri, 13 Nov 2026 02:11:21 +0900</pubDate><guid>https://linux.meerstory.com/ja/ubuntu/20261113_021039_303/</guid><description>&lt;h2 id="概要">概要&lt;/h2>
&lt;p>開発者が日常的に実行する &lt;code>git push&lt;/code> の裏側では、リモートホスト上で低レベルの配管（plumbing）コマンドである &lt;code>git-receive-pack&lt;/code> が呼び出され、送受信のハンドシェイクやオブジェクト格納を担っています。本記事では、Linuxターミナル上でベア（bare）リポジトリをゼロから構築し、パケットレベルのプロトコル挙動や参照（ref）更新がどのように処理されるのかを実践的に探ります。&lt;/p>
&lt;h2 id="gitパッケージのセットアップと実行パスの特定">Gitパッケージのセットアップと実行パスの特定&lt;/h2>
&lt;p>まずは検証に必要なGitツールチェーンをUbuntu環境へ導入するため、リポジトリキャッシュの同期とパッケージインストールを実施します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261113_021039_303/captures/s01_c01_apt-get_update_-qq____apt-get_install_-y_git.png"
 alt="パッケージの更新およびGitの導入"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>バイナリが正常に配置されたか確認を兼ねて、システムのGitバージョンを取得します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261113_021039_303/captures/s01_c02_git_--version.png"
 alt="Gitバージョンの表示"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>プッシュトラフィックを受け取ってリポジトリを同期する中核デーモンプロセス、&lt;code>git-receive-pack&lt;/code> の配置ディレクトリを調査します。&lt;br>
⚙️ [主要パラメーター]&lt;/p>
&lt;p>&lt;code>&amp;lt;directory&amp;gt;&lt;/code> : クライアントからの更新を反映させる対象リポジトリのパスを指定します。&lt;br>
&lt;code>--http-backend-info-refs&lt;/code> : Smart HTTPプロトコル通信時に info/refs エンドポイント用リファレンス一覧を出力させる際に利用されます。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261113_021039_303/captures/s01_c03_which_git-receive-pack.png"
 alt="git-receive-packのパス確認"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;h2 id="検証用ベアリポジトリの初期化">検証用ベアリポジトリの初期化&lt;/h2>
&lt;p>実験用の独立した作業領域として &lt;code>/tmp/git-lab&lt;/code> を確保し、当該パスへ作業ディレクトリを切り替えます。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261113_021039_303/captures/s02_c01_mkdir_-p__tmp_git-lab____cd__tmp_git-lab.png"
 alt="実験用作業ディレクトリの作成と移動"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>リモートサーバーのリポジトリ構造をシミュレートするため、ワーキングツリーを持たない純粋なストレージであるベアリポジトリ &lt;code>server.git&lt;/code> を立ち上げます。&lt;br>
クライアントから送られる変更パケットは、このリポジトリ上で起動する &lt;code>git-receive-pack&lt;/code> によって永続化されます。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261113_021039_303/captures/s02_c02_git_init_--bare_server_git.png"
 alt="ベアリポジトリ server.git の初期化"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>作成された &lt;code>server.git&lt;/code> ディレクトリ直下の構成をリストアップし、&lt;code>HEAD&lt;/code> や &lt;code>config&lt;/code>、オブジェクト群を抱える &lt;code>objects&lt;/code>、ブランチ参照を保持する &lt;code>refs&lt;/code> など、Gitの基本メタ構造が整っていることを確認します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261113_021039_303/captures/s02_c03_ls_-la_server_git.png"
 alt="server.git 内のファイル構造一覧"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>ブランチやタグのリファレンスが書き込まれる &lt;code>server.git/refs&lt;/code> ディレクトリの初期状態を調べ、&lt;code>heads&lt;/code> および &lt;code>tags&lt;/code> のベース構成が定義されているか検証します。&lt;/p></description></item></channel></rss>