2015-04-28 56 views

回答

2

每個子模塊一個簡單的狀態可以給你他們各自國家的良好表示:

git submodule foreach "git status || true" 

請參閱「Use git submodule foreach with function」爲更復雜的腳本,在git submodule foreach命令的組合運行。

,將顯示推狀態,僅當:

  • your module is configured to follow a branch。 (否則,子模塊被簽出作爲一個分離的頭,並提交狀態將是空的,推的狀態不存在)

    git config -f .gitmodules submodule.<path>.branch <branch> 
    git submodule update --init --remote 
    
  • 一個分支已簽出(並提交完成)

    cd asubmodule 
    git checkout master 
    # add and commit 
    

(請參閱 「Git submodule is in 「detached head」 state after cloning and submodule update」)

然後命令將工作(例如爲'compose' submodule of the project b2d):

[email protected] MINGW64 /c/Users/VonC/prog/b2d (master) 
$ git submodule foreach "git status || true" 
Entering 'compose' 
On branch master 
Your branch is ahead of 'origin/master' by 1 commit. 
    (use "git push" to publish your local commits) 
nothing to commit, working directory clean 
+0

顯示提交狀態,而不是推送狀態。 – adrelanos

+0

@adrelanos它會顯示推送狀態(我只是測試它),但我的回答缺少必要的步驟,使推送狀態可見。我修改了我的答案。 – VonC

相關問題