Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git子模块总是签出特定的提交_Git_Git Submodules - Fatal编程技术网

Git子模块总是签出特定的提交

Git子模块总是签出特定的提交,git,git-submodules,Git,Git Submodules,我的git子模块之一总是签出特定的提交: 首先,它在主存储库中显示为已修改: % git status

我的git子模块之一总是签出特定的提交:

首先,它在主存储库中显示为已修改:

 % git status                                                                                                                                                                                                         
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

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:   wp-content/themes/site-wp-theme (new commits)
正在尝试更新:

% git submodule update                                                                                                                                                                                               
warning: unable to rmdir admin/inc/cmb: Directory not empty
warning: unable to rmdir admin/inc/redux: Directory not empty
Submodule path 'wp-content/themes/site-wp-theme': checked out 'c010f3a0b6e5c4721d8e79d312b1fffa342340b8'
因此,我必须转到子模块,并执行
git checkout master
来恢复它,这使得它在修改后的
git status
上再次显示

这是我的
.gitmodules
文件:

[submodule "site"]
    path = wp-content/themes/site-wp-theme
    url = https://ajf-@bitbucket.org/ajf-/site-wp-theme.git
    fetchRecurseSubmodules = true
    ignore = untracked
[submodule "siteny"]
    path = wp-content/themes/wp-siteny-theme
    url = https://ajf-@bitbucket.org/ajf-/wp-siteny-theme.git
    fetchRecurseSubmodules = true
    ignore = untracked

如何解决此问题?

git子模块更新
将使父repo在其注册的SHA1处更新子模块,而不是在该子模块中修改的SHA1处更新子模块

如果父回购协议的状态显示子模块的修改SHA1,则您只需执行以下操作:

  • 确保已将子模块推送到其自己的上游bitucket repo
  • 返回到父repo、git add、git commit和git push,以便在表示子模块的gitlink中注册子模块的新状态(gitlink是最新状态)

git子模块更新
检查git认为应该提交的所有子模块;这就像子模块的git签出。

相反,您希望通过将该修订提交给父回购协议来告诉git它应该是
9eb1fbd

为此:

  • 进入子模块并检查提交。如果它是您刚刚进行的新提交,请确保它被推送到子模块的上游,以便其他协作者能够将其拉入
  • 进入母公司回购;子模块应标记为具有“新提交”,因为签出版本与提交给父repo的版本不同
  • 直接提交子模块路径,就像它是任何其他文件一样。它可以是包含其他更改的提交的一部分,也可以只是它自己
[submodule "site"]
    path = wp-content/themes/site-wp-theme
    url = https://ajf-@bitbucket.org/ajf-/site-wp-theme.git
    fetchRecurseSubmodules = true
    ignore = untracked
[submodule "siteny"]
    path = wp-content/themes/wp-siteny-theme
    url = https://ajf-@bitbucket.org/ajf-/wp-siteny-theme.git
    fetchRecurseSubmodules = true
    ignore = untracked