日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Git submodule子模块

發(fā)布時(shí)間:2024/2/28 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Git submodule子模块 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1. 子模塊的添加

git submodule add <url> <path>

其中,url為子模塊的路徑,path為該子模塊存儲(chǔ)的目錄路徑。

比如:

git submodule add https://github.com/openresty/echo-nginx-module.git external/echo-nginx-module

?

執(zhí)行成功后,git status會(huì)看到項(xiàng)目中修改了.gitmodules,并增加了一個(gè)新文件(為剛剛添加的路徑)

root@dispatch:/home/Xlon# git status On branch feature_ai_20190712 Your branch is up-to-date with 'origin/feature_ai_20190712'. Changes to be committed:(use "git reset HEAD <file>..." to unstage)modified: .gitmodulesnew file: external/echo-nginx-module

git diff --cached查看修改內(nèi)容可以看到增加了子模塊,并且新文件下為子模塊的提交hash摘要

git commit提交即完成子模塊的添加
git push 推送到倉庫就ok了

?

2. submodule 的使用

git submodule init

git submodule update

?

3.?.gitmodules 和.git/config

Git在兩個(gè)地方存儲(chǔ)有關(guān)子模塊的信息。第一個(gè)是在一個(gè)名為的文件中.gitmodules,該文件被簽入git存儲(chǔ)庫。對此文件的更改將傳播到其他存儲(chǔ)庫。

另一個(gè)位置在.git/config。

當(dāng)更新存儲(chǔ)庫時(shí),您.gitmodules將更新文件的副本,但不會(huì)更新您的.git/config文件; 當(dāng)想要從新網(wǎng)址開始簽出時(shí),執(zhí)行g(shù)it submodule sync以將新配置從中復(fù)制.gitmodules到.git/config。

?

?

重點(diǎn):

刪除Submodule

git?并不支持直接刪除Submodule需要手動(dòng)刪除對應(yīng)的文件:

cd pod-project

git rm --cached pod-library rm -rf pod-library rm .gitmodules

更改git的配置文件config:
vim .git/config

可以看到Submodule的配置信息:

[submodule "pod-library"]url = git@github.com:jjz/pod-library.git

刪除submodule相關(guān)的內(nèi)容,然后提交到遠(yuǎn)程服務(wù)器:

git commit -a -m 'remove pod-library submodule'

git push branch? , 上傳到遠(yuǎn)程分支

總結(jié)

以上是生活随笔為你收集整理的Git submodule子模块的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。