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

詳解git submodule HEAD detached 的問(wèn)題

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

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

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

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


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

解決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

簡(jiǎn)單的一行命令遞歸修復(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 的問(wèn)題的文章就介紹到這了,更多相關(guān)git submodule HEAD detached內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論