2016-07-15 19 views
0

私はgitリポジトリmainrepoをクローンしました。サブモジュールはsubmodule1です。私はsubmodule1から最新のアップデートを取得しようとすると:git submodule update --remoteは機能しません

$ cd mainrepo 

$ git submodule add [email protected]:myaccount/submodule1.git 

$ git submodule update --remote submodule1 
Usage: git submodule [--quiet] add [-b branch] [--reference <repository>] [--] <repository> [<path>] 
    or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...] 
    or: git submodule [--quiet] init [--] [<path>...] 
    or: git submodule [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...] 
    or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...] 
    or: git submodule [--quiet] foreach [--recursive] <command> 
    or: git submodule [--quiet] sync [--] [<path>...] 

$ git submodule update --remote 
Usage: git submodule [--quiet] add [-b branch] [--reference <repository>] [--] <repository> [<path>] 
    or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...] 
    or: git submodule [--quiet] init [--] [<path>...] 
    or: git submodule [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...] 
    or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...] 
    or: git submodule [--quiet] foreach [--recursive] <command> 
    or: git submodule [--quiet] sync [--] [<path>...] 

を私はかつてsubmodulesこの方法を更新しようとしたと確信して、ドキュメントがあまりにもそうするように言って、まだそれが動作しない理由を私は理解していません。

しかし、私はそれをしたいと私はフェッチとsubmoduleに直接マージし、それが最新のリポジトリに更新されない場合は、コミット:

$ cd submodule1 

$ git fetch && git merge master 

なぜsubmodule update --remote submodule1コマンドの仕事ではないのですか?

たぶんそれが役立つかもしれない:

$ vim mainrepo/.git/config 
[core] 
     repositoryformatversion = 0 
     filemode = true 
     bare = false 
     logallrefupdates = true 
[remote "origin"] 
     fetch = +refs/heads/*:refs/remotes/origin/* 
     url = [email protected]:myaccount/mainrepo.git 
[branch "master"] 
     remote = origin 
     merge = refs/heads/master 
[submodule "local/src/utils"] 
     url = [email protected]:myaccount/submodule1.git 

$ vim .gitmodules 
[submodule "submodule1"] 
     path = submodule1 
     url = [email protected]:myaccount/submodule1.git 
+2

どのバージョンのgit( 'git --version')ですか? – larsks

+0

そのコンピュータのgitバージョンは1.7.1です...リモートサブモジュールの更新は私のパーソナルコンピュータで動作し、gitバージョンは2.9.0にアップデートされています。 – kaligne

答えて

1

を私はgitのからサブモジュールにこのクラッシュのコースを読んで推薦:https://git-scm.com/book/en/v2/Git-Tools-Submodules

私の推測では、すでにクローン化されたリポジトリがサブモジュールを持っているので(かどうかを確認、ということですレポのルートに.gitmodules!)再びgit submodule addする必要はありません。

リポジトリをクローン化してから、git submodule update --recursiveを実行すれば十分です。

また、git clone --recurse-submodulesはこれを自動的に行います。

関連する問題