TortoiseGit サブモジュールを含むリポジトリを取得する手順2/2

前半に引き続き、無料のバージョン管理ソフト Git のクライアントソフト TortoiseGit を用いて、 PC 内に作成したリモートリポジトリを、新規作成した空のフォルダにクローン(複製)して、指定したリモートリポジトリのブランチチェックアウトします。
その後、クローンだけではチェックアウトされないサブモジュールのファイル群をチェックアウトします。

TortoiseGit ダウンロードとインストール1

※ TortoiseGit-2.17.0.2-64bit を使用します。

前半の記事

サブモジュールを作業ディレクトリにチェックアウト

サブモジュールのファイル群をチェックアウトするには、作業ディレクトリをエクスプローラで開いて、右クリックして表示されるメニュー「TortoiseGit」→「サブモジュールのアップデート」を選択します。

TortoiseGit サブモジュールを含むリポジトリをローカルに取得する手順8

「サブモジュールを更新」ダイアログが表示されます。
最初のアップデートのためか、最初から「サブモジュールを初期化する(–init)」にチェックが入っています。

サブモジュールのパス(例では Gut)を選択して、サブモジュール内のサブモジュールにも処理を適用するように「再帰的」にチェックを入れて OK ボタンを押します。

TortoiseGit サブモジュールを含むリポジトリをローカルに取得する手順9

Initialize the submodules and/or update the registered submodules, i.e. clone missing submodules and checkout the commit specified in the index of the containing repository.

サブモジュールを初期化し、登録されたサブモジュールを更新します。つまり、不足しているサブモジュールを複製し、含まれるリポジトリのインデックスで指定されたコミットをチェックアウトします。

Submodules – TortoiseGit – Documentation – TortoiseGit – Windows Shell Interface to Git と Google 翻訳
git.exe submodule update --progress --init --recursive

上記コマンドが実行されました。

先ほど選択したサブモジュール third_party/Gut は、以前に .gitmodules ファイルで設定した通り、フォークしたリポジトリの URL にアクセスして更新していることが確認できます。

TortoiseGit サブモジュールを含むリポジトリをローカルに取得する手順10
git.exe submodule update --progress --init --recursive
Submodule 'third_party/Gut' (https://github.com/sakura-crowd/Gut.git) registered for path 'third_party/Gut'
Cloning into 'G:/Dev/Godot4GD/SakuraCrowd/tmp/SakuraCrowdGodotLib/third_party/Gut'...
remote: Enumerating objects: 8991, done.
remote: Counting objects: 100% (2030/2030), done.
remote: Compressing objects: 100% (574/574), done.
remote: Total 8991 (delta 1758), reused 1457 (delta 1455), pack-reused 6961 (from 3)
Receiving objects: 100% (8991/8991), 6.15 MiB | 8.64 MiB/s, done.
Resolving deltas: 100% (5816/5816), done.
Submodule path 'third_party/Gut': checked out '5043bfe1f3bc6e32ba3dd181ee8b99fe088c70a4'

成功 (4703 ms @ 2025/08/04 16:23:38)

Inspects, updates and manages submodules.
For more information about submodules, see gitsubmodules[7].

サブモジュールを検査、更新、管理します。 サブモジュールの詳細については、gitsubmodules[7] を参照してください。

Update the registered submodules to match what the superproject expects by cloning missing submodules, fetching missing commits in submodules and updating the working tree of the submodules. The “updating” can be done in several ways depending on command line options and the value of submodule.<name>.update configuration variable. The command line option takes precedence over the configuration variable. If neither is given, a checkout is performed. (note: what is in .gitmodules file is irrelevant at this point; see git submodule init above for how .gitmodules is used). The update procedures supported both from the command line as well as through the submodule.

欠落しているサブモジュールのクローンを作成し、サブモジュール内の欠落しているコミットをフェッチし、サブモジュールの作業ツリーを更新することにより、スーパープロジェクトが期待するものと一致するように登録されたサブモジュールを更新します。 「更新」は、コマンド ライン オプションと submodule..update 構成変数の値に応じて、いくつかの方法で行うことができます。コマンド ライン オプションは構成変数よりも優先されます。どちらも指定されていない場合は、チェックアウトが実行されます。 (注: .gitmodules ファイルの内容はこの時点では関係ありません。.gitmodules の使用方法については、上記の git submodule init を参照してください)。更新手順は、コマンド ラインとサブモジュールの両方からサポートされました。

If --recursive is specified, this command will recurse into nested submodules, and show their status as well.

–recursive が指定されている場合、このコマンドはネストされたサブモジュールを再帰的に実行し、そのステータスも表示します。

Git – git-submodule Documentation と Google 翻訳

アップデート前は空だったサブモジュールのフォルダに、指定した URL から取得したファイルがチェックアウトされました。

このサブモジュールに対応するローカルリポジトリはサブモジュールのフォルダの .git ファイル内に相対パスで記述されていて、作業ディレクトリの .git/modules/ フォルダ内にあることが確認できます。

TortoiseGit サブモジュールを含むリポジトリをローカルに取得する手順11
gitdir: ../../.git/modules/third_party/Gut

まとめ

今回は、全2話で、無料のバージョン管理ソフト Git のクライアントソフト TortoiseGit を用いて、 PC 内に作成したリモートリポジトリを、新規作成した空のフォルダにクローン(複製)して、指定したリモートリポジトリのブランチチェックアウトして、その後、クローンだけではチェックアウトされないサブモジュールのファイル群をチェックアウトしました。

参照サイト Thank You!

記事一覧 → Compota-Soft-Press

コメント

Ads Blocker Image Powered by Code Help Pro

お願い - Ads Blocker Detected

このサイトは広告を掲載して運営しています。

ポップアップを閉じて閲覧できますが、よろしければ

このサイト内の広告を非表示にする拡張機能をオフにしていただけませんか?

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

タイトルとURLをコピーしました