我有一个带有单个子模块的超级项目。该子模块完全独立于超级项目开发,但这不是我的超级项目设置方式。目前,当子模块的来源得到更新时,如果有人(我)运行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