欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解git submodule HEAD detached 的問題

 更新時(shí)間:2020年08月21日 09:50:49   作者:YuZhuQue  
這篇文章主要介紹了詳解git submodule HEAD detached 的問題,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

在使用git submodule 的時(shí)候,常常會遇到 執(zhí)行完以下操作后發(fā)現(xiàn) 子倉庫的head 指針處于游離狀態(tài)

  • git clone xxxxx.git
  • git submodule update --init

然后切換到子倉庫,查看當(dāng)前分支的狀態(tài)如下


原因是之前同事在子倉庫中修改并提交后,沒有在 父倉庫中更新子倉庫的最新提交記錄
正常情況下,修改子倉庫的內(nèi)容并在子倉庫提交后會在父倉庫執(zhí)行 git diff會有如下輸出

解決git submodule head detached的方法:

重新建立submodule,加入時(shí)使用-b參數(shù),使得母項(xiàng)目追蹤子項(xiàng)目的指定branch(否則默認(rèn)不追蹤):

git submodule add -b <branch> <repository> [<submodule-path>]
git submodule update --remote

簡單的一行命令遞歸修復(fù)所有子項(xiàng)目的detached head(其中默認(rèn)都追蹤子項(xiàng)目的master branch):

git submodule foreach -q --recursive 'git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch || echo master)'

參考

Why is my Git Submodule HEAD detached from master?
Git submodules best practices

到此這篇關(guān)于詳解git submodule HEAD detached 的問題的文章就介紹到這了,更多相關(guān)git submodule HEAD detached內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論