我有一個帶有單個子模塊的超級項目。該子模塊完全獨立於超級項目開發,但這不是我的超級項目設置方式。目前,當子模塊的來源得到更新時,如果有人(我)運行git submodule update --recursive --remote
,然後將該更新提交給超級項目,則只會更新超級項目。那很愚蠢;我不跟蹤任何版本或提交我的超級項目中子模塊的散列。我想要的是在我的超級項目中擁有子模塊的起源/主人,無論起源/主人是什麼。我只想要同步子模塊,而不是將子模塊提交到我的超級項目中。git子模塊:如何保持子模塊當前不提交到超級項目?
例如,做一個git clone
,爲了得到子模塊後,我跑git submodule update --init --recursive
並獲得這樣的:
$ git submodule update --init --recursive
Submodule 'scripts/token' (https://gitserver.company.com/token.git) registered for path 'scripts/token'
Submodule path 'scripts/token': checked out '93b6bee2031913f563f548883358a65a136bdd88'
但提交哈希93b6bee2031913f563f548883358a65a136bdd88不是令牌回購的起源/主;那是0f39201818985d21a1f2362ad5b519793bd4f2b6。爲了得到這一點,我已經運行另一個git submodule
命令:
$ git submodule update --recursive --remote
Cloning into '/Users/me/superproject/scripts/token'...
Submodule path 'scripts/token': checked out '0f39201818985d21a1f2362ad5b519793bd4f2b6'
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: scripts/token (new commits)
沒有,我沒有「新提交」到上層項目;我剛剛同步了一個子模塊。我希望這個工作像一個依賴;我想token>=0.0.1
(無論是起源/主),但它似乎是我所擁有的是token=explicit_commit_hash
。我不想在我的超級項目中支持版本號或提交子模塊標記的哈希值。
UPDATE:換句話說,如果git status
說:「跟上時代的」不當地修改運行git submodule update
前,然後git submodule update
更新子模塊後,我還是想git status
說「上的最新」沒有本地變化。
我在做什麼錯?
我正在尋找的是一切都交給了'git的commit'。我不想讓子模塊更新甚至被視爲修改後的代碼。如果'git status'說的是「最新的」,那麼在'git submodule update'更新子模塊之後,我仍然希望'git status'說「最新」而不需要本地修改。 – DrStrangepork