Git シンボリックリンクを含むリポジトリの取得(clone)を行う手順2/2

無料ソースコード管理 (SCM: software configuration management) ソフト Git for Windows を用いて、GitHub で公開されているシンボリックリンクを含むリポジトリを、 git clone コマンドを使ってローカルに複製する手順を紹介します。
Windows 版の Git でシンボリックリンクに対応するための設定や、複製したシンボリックリンクの注意点についても紹介します。

git-scm 公式サイトの一部 20250408

※Git-2.49.0 (64 bit) を使用します。
※例として GitHub で公開されている denismm/dmmlib リポジトリを clone

前回の記事

前半では、シンボリックリンクを含むリポジトリを、 git clone コマンドを使ってローカルに複製しました。

今回の後半では、そのリポジトリフォルダ正常であることの確認と、シンボリックリンクを windows で扱う際の注意点対処法について紹介します。

シンボリックリンクを含むリポジトリの確認

前回シンボリックリンクを含むリポジトリを clone(複製)したローカルのワーキングツリーが差分を含まない正常な状態かを、git status コマンドを使って確認します。

Show the working tree status

Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working tree and the index file, and paths in the working tree that are not tracked by Git (and are not ignored by gitignore[5]). The first are what you would commit by running git commit; the second and third are what you could commit by running git add before running git commit.

作業ツリーのステータスを表示する

インデックス ファイルと現在の HEAD コミットの間に差異があるパス、作業ツリーとインデックス ファイルの間に差異があるパス、Git によって追跡されない (gitignore[5] によって無視されない) 作業ツリー内のパスを表示します。 1 つ目は、git commit を実行してコミットする内容です。 2 番目と 3 番目は、git commit を実行する前に git add を実行することでコミットできるものです。
Git – git-status Documentation

cd コマンドでリポジトリフォルダに移動して、 git status コマンドを実行すると、「nothing to commit, working tree clean(Google翻訳:コミットするものは何もなく、作業ツリーはクリーンです)」と表示され、シンボリックリンクも含めて正常に clone (複製)できたことが確認できました。

GitForWindows シンボリックリンクのあるリポジトリの取得12
g:\Dev\Mistical>cd dmmlib

g:\Dev\Mistical\dmmlib>git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

注意点:シンボリックリンクは移動で通常のファイルに変わってしまう

シンボリックリンクを含むリポジトリを clone (複製) したあとに、そのシンボリックリンクやそれを含むフォルダを移動すると、シンボリックリンクが参照先の内容を持つファイルに変わってしまいます。

GitForWindows シンボリックリンクのあるリポジトリの取得13

シンボリックリンクの lines.ps も移動すると種類.symlink から PSファイルに変わっています。
内容も、シンボリックリンクではなく、シンボリックリンクが指していたファイルの内容に置き換わっています。

GitForWindows シンボリックリンクのあるリポジトリの取得14

対処法:設置場所でシンボリックリンク対応のクローン(複製)を実行

シンボリックリンクは移動すると、参照先の内容を持つファイルに変わってしまうので、移動せずに済むように最初から配置する場所で git clone コマンドを実行して、リポジトリを複製しましょう。

GitForWindows シンボリックリンクのあるリポジトリの取得15
g:\Dev\Mistical\dmmlib>cd ..\mystical_ps-main\mystical_ps-main

g:\Dev\Mistical\mystical_ps-main\mystical_ps-main>git clone -c core.symlinks=true https://github.com/denismm/dmmlib.git
fatal: destination path 'dmmlib' already exists and is not an empty directory.

g:\Dev\Mistical\mystical_ps-main\mystical_ps-main>git clone -c core.symlinks=true https://github.com/denismm/dmmlib.git
Cloning into 'dmmlib'...
remote: Enumerating objects: 414, done.
remote: Counting objects: 100% (207/207), done.
remote: Compressing objects: 100% (123/123), done.
remote: Total 414 (delta 120), reused 165 (delta 80), pack-reused 207 (from 1)
Receiving objects: 100% (414/414), 859.71 KiB | 7.41 MiB/s, done.
Resolving deltas: 100% (216/216), done.

例えば、GitHub の denismm/mystical_ps では、サブフォルダに先ほどの denismm/dmmlib配置する必要があるので、 mystical_ps のリポジトリを複製した後、そのリポジトリフォルダ内に cd コマンドで移動してからシンボリックリンクを含むリポジトリを clone (複製) します。

まとめ

前回から引き続き、無料ソースコード管理 (SCM: software configuration management) ソフト Git for Windows を用いて、GitHub で公開されているシンボリックリンクを含むリポジトリを、 git clone コマンドを使ってローカルに複製する手順を紹介しました。
Windows 版の Git でシンボリックリンクに対応するための設定や、複製したシンボリックリンクの注意点についても紹介しました。

参照サイト 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をコピーしました