2012-02-06 44 views
4

比方說,我有一個父回購myproject,並呼籲submodule一個單獨的回購協議,目錄結構是這樣的以下內容:提交更改到一個子模塊,而無需提交母公司回購

 

    root$ find . -not -path *.git* 
    . 
    ./myproject 
    ./myproject/submodule 

現在我想補充submodule作爲myproject的子模塊。

 

    root$ cd myproject 
    myproject$ git submodule add git://url-to-submodule:submodule.git submodule 
    Adding existing repo at 'submodule' to the index 

現在,假設我改變了一些東西到submodule

 

    myproject$ cd submodule 
    submodule$ touch herpin.txt 
    submodule$ add herpin.txt 
    submodule$ git commit -am "i'm herpin and i'm derpin" 

在這一點上,我回去給家長資源庫,並檢查git的狀態:

 

    submodule$ cd .. 
    myproject$ git status 
    # On branch master 
    # Changes not staged for commit: 
    # (use "git add ..." to update what will be committed) 
    # (use "git checkout -- ..." to discard changes in working directory) 
    # 
    # modified: submodule (new commits) 
    # 
    no changes added to commit (use "git add" and/or "git commit -a") 

好,該死的 - 現在每一次我犯子模塊的東西,我也有提交父母。

如果您有更復雜的子模塊樹,它會很快變得煩人。假設 - 4層深。如果我在最內層的子模塊上做出改變,我必須承諾它的母公司,祖父母,曾祖父母和偉大父母。這是一個驚人的痛苦---。

必須有更好的方法! (不,沒有嵌套如此多的層次不是一個選項:/這不是我的要求......)沒有一種方式可以讓git-commit通知父庫提交的內容嗎?

回答

1

你當然可以爲此編寫自己的腳本。後提交鉤將是一個很好的地方。但我不確定這是否是您想要的,因爲我認爲這個想法是,不是要複製包含存儲庫的每個提交,而是要有不同層次的抽象。即將一系列提交到子模塊中的一組提交到超級庫的一個提交中,然後以不太詳細的方式(子模塊:實現的特徵x)來描述改變。