簡體   English   中英

將本地存儲庫推送到遠程控制器不會使用GIT推送子模塊文件

[英]Pushing local repo to remote does not push submodule files using GIT

我是GIT的新手並且正在努力解決這個問題。 我有一個存儲在存儲庫中的網站。 該網站需要一個主題文件夾,該文件夾設置為單獨的存儲庫。

我已成功使用git submodule add命令將主題存儲庫添加到我的網站。

所以現在我有一個主題兒童repro的網站repro。 子模塊的文件顯示在我的網站文件夾中。

我正在嘗試將整個主網站repro推送到遠程服務器,該服務器可以工作但主題文件(子模塊)不會被推送。

子模塊非常像一個獨立的存儲庫 - 它不知道它是否被包含在父存儲庫中作為子模塊。 父存儲庫對子模塊的了解不多 - 它應該在樹中的位置,子模塊應該在什么位置提交以及最初克隆它的URL ...

我不認為有一個命令會為你推送所有的子模塊 - 更新子模塊中的一些文件時的事件序列應該是:

 cd theme

 # [Change or add some files, etc.]

 # Now commit those changes:
 git commit -a

 # Push them to the origin repository, assuming you're on the master branch:
 git push origin master

 # Change up to the parent repository:
 cd ..

 # Create a commit with the new version of that submodule:
 git add theme
 git commit -m "Committing a new version of the theme submodule"

 # Now push the commit that includes a pointer to the new submodule
 # version in the parent repository:
 git push origin master

這里的典型問題是在父存儲庫中推送提交,該提交引用了尚未從子模塊版本推送的子模塊版本。 您可能會發現創建腳本很有幫助,這樣您就不會忘記任何這些步驟。

我只是將themes目錄添加為遠程 - 而不是子模塊。 管理您自己分支中的文件位置。 主題的后續更新應移至正確的文件夾。

推送現在將按照您的預期行事。

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM