2017-05-17 3 views
0

Wenn ich mein Git-Projekt, das Submodule verwendet, holen, haben die Submodule einen abgetrennten Kopf. Ich lese viele Beiträge hier auf Stackoverflow und sie sagen, dass dieses Problem gelöst werden sollte - also mache ich etwas falsch, kann aber nicht erkennen was.Git Submodule noch mit losem Kopf

Das ist, was passiert:

M.Grunwald % git clone -b BranchName ssh://[email protected]:7999/~m.grunwald/repo_with_submodules.git some_repo 
Cloning into 'some_repo'... 
remote: Counting objects: 26, done. 
remote: Compressing objects: 100% (26/26), done. 
remote: Total 26 (delta 9), reused 0 (delta 0) 
Receiving objects: 100% (26/26), done. 
Resolving deltas: 100% (9/9), done. 
M.Grunwald % cd some_repo 
M.Grunwald % cat .gitmodules 


[submodule "Library/MyLib"] 
     path = Library/MyLib 
     url = ssh://[email protected]:7999/~m.grunwald/my_lib.git 
     branch = BranchName 


M.Grunwald % git submodule init 
Submodule 'Library/MyLib' (ssh://[email protected]:7999/~m.grunwald/my_lib.git) registered for path 'Library/MyLib' 
M.Grunwald % git submodule update --remote 
Cloning into 
'/cygdrive/c/Users/m.grunwald/Documents/TMP/some_repo/Library/MyLib'... 
Submodule path 'Library/MyLib': checked out '5c665e00cca5eb24d9b615294807520a6036fa90' 
git submodule update --remote 4.31s user 10.61s system 10% cpu 2:21.52 total 
M.Grunwald % cd Library/MyLib 
M.Grunwald % git status 
HEAD detached at 5c665e0 
nothing to commit, working tree clean 

Also, die .gitmodules das Submodul enthält, darunter „Zweig = branch“ und ich rufe Submodul Update mit --remote ... Was noch fehlt?

% git --version git Version 2.12.3

Das ist, was passiert, wenn ich zu wechseln branch (CWD ist some_repo/Library/MyLib):

M.Grunwald% git branch -r 
    origin/HEAD -> origin/master 
    origin/BranchName 
M.Grunwald % git checkout BranchName 
Branch BranchName set up to track remote branch BranchName from origin. 
Switched to a new branch 'BranchName' 
M.Grunwald % git status 
On branch BranchName 
Your branch is up-to-date with 'origin/BranchName'. 
nothing to commit, working tree clean 
M.Grunwald % cd .. 
M.Grunwald % .. 
M.Grunwald % git status 
On branch BranchName 
Your branch is up-to-date with 'origin/BranchName'. 
Changes not staged for commit: 
    (use "git add <file>..." to update what will be committed) 
    (use "git checkout -- <file>..." to discard changes in working directory) 
    (commit or discard the untracked or modified content in submodules) 

     modified: Library/MyLib (new commits) 

M.Grunwald % git diff Library/MyLib 
diff --git a/Library/MyLib b/Library/MyLib 
index 1341b30..5c665e0 160000 
--- a/Library/MyLib 
+++ b/Library/MyLib 
@@ -1 +1 @@ 
-Subproject commit 1341b30ae55df1afc7265a9110fbf09661dd627b 
+Subproject commit 5c665e00cca5eb24d9b615294807520a6036fa90 
+0

Welche Version von Git verwenden Sie? –

+0

Und wenn Sie 'BranchName' in Ihrem Submodul auschecken, sehen Sie eine Änderung im Superprojekt? –

+0

Hallo Nils, siehe mein Update – Markus

Antwort

0

mir Sieht normal. Was genau ist dein Problem? Ein Submodul befindet sich immer in einem gelösten Kopfzustand, auch wenn es richtig eingerichtet ist, um einen Zweig zu verfolgen (siehe Link unten). Wenn Sie Zweige in Ihrem übergeordneten Repository wechseln, müssen Sie git submodule update ausführen, um Ihre Submodule auf das Commit des neuen Zweigs zu aktualisieren, falls es anders ist.

Von this answer, die genau zu adressieren scheint, was Sie wissen wollen:

Beachten Sie, dass das Ergebnis für jede aktualisierte Submodul, wird immer ein abgelöst HEAD, wie Dan Cameron Ton in seiner Antwort.