この問題を再現するためのテストbashスクリプトは、git --version
は "git version 1.9.1"です。基本的に、私は、「ソース親プロジェクト」/tmp/TestMain
レポにサブモジュールとして使用「ソースサブモジュール」レポ/tmp/TestSubber
を、持っている - と私は/tmp/TestLocMain
として、クローンに「ローカル」クローンを作成するソースは、サブモジュールを初期化します。git detached headが原因で 'git submodule update'が失敗しました 'fatal:1つのリビジョンが必要'
set -x
rm -rfv /tmp/TestSubber /tmp/TestMain /tmp/TestLocMain
mkdir /tmp/TestSubber /tmp/TestMain
cd /tmp/TestSubber; git init;
git config user.name me; git config user.name [email protected];
echo "aaaa" >> a.txt ; git add a.txt; git commit -m 'commit 01'
echo "aaaa" >> a.txt ; git add a.txt; git commit -m 'commit 02'
echo "aaaa" >> a.txt ; git add a.txt; git commit -m 'commit 03'
echo "aaaa" >> a.txt ; git add a.txt; git commit -m 'commit 04'
git checkout HEAD~2
git status # HEAD detached at f221985
cd /tmp/TestMain; git init;
git config user.name me; git config user.name [email protected];
echo "bbbb" >> b.txt ; git add b.txt; git commit -m 'commit 01'
git submodule add -b master --depth 1 -- https://github.com/rtyley/small-test-repo TestSubber
git add -u; git commit -m 'added submodule'
cd /tmp
git clone file:///tmp/TestMain /tmp/TestLocMain
cd TestLocMain
sed -i"" 's!https://github.com/rtyley/small-test-repo!file:///tmp/TestSubber!g' .gitmodules
git submodule sync
git submodule update --init --remote --depth 1 --merge -- TestSubber
このスクリプトを実行すると、git submodule update
との最後のステップはで失敗します:
...
+ git submodule update --init --remote --depth 1 --merge -- TestSubber
Submodule 'TestSubber' (file:///tmp/TestSubber) registered for path 'TestSubber'
Cloning into 'TestSubber'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
Checking connectivity... done.
From file:///tmp/TestSubber
* branch HEAD -> FETCH_HEAD
fatal: Needed a single revision
Unable to find current origin/master revision in submodule path 'TestSubber'
は一見問題がデタッチHEAD状態でそのレポを強制的に元のサブモジュールレポ/tmp/TestSubber
、中git checkout HEAD~2
です。
...
+ git submodule update --init --remote --depth 1 --merge -- TestSubber
Submodule 'TestSubber' (file:///tmp/TestSubber) registered for path 'TestSubber'
Cloning into 'TestSubber'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
Checking connectivity... done.
Submodule path 'TestSubber': checked out 'ad110f4932339fe5efb940608139b08a28b8c518'
は今、私の実際のユースケースは何
TestSubber
に対応することは巨大であるということで、当面はデタッチHEAD状態のままにする必要があります:あなたが行
git checkout HEAD~2
コメント場合、最終的な段階ではと成功します。サブモジュールの更新を
TestLocMain
に強制的に完了させるには、
TestSubber
の状態を変更せずに何かできますか?