Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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";“超级模块”;使用带有grunt git和grunt githooks的子模块的提交后钩子_Git_Gruntjs_Git Submodules_Githooks_Post Commit Hook - Fatal编程技术网

提交Git";“超级模块”;使用带有grunt git和grunt githooks的子模块的提交后钩子

提交Git";“超级模块”;使用带有grunt git和grunt githooks的子模块的提交后钩子,git,gruntjs,git-submodules,githooks,post-commit-hook,Git,Gruntjs,Git Submodules,Githooks,Post Commit Hook,我有一个包含许多子模块的git repo。当我在子模块中提交时,我有一个git钩子,它应该在“超级模块”中提交。不幸的是,post-commit钩子中的提交失败,因为“超级模块”似乎无法检测其子模块中的更改 有没有其他方法可以实现这种行为 我通过Grunt使用GruntGitHooks和GruntGit设置了所有这些 下面是我的Grunfile文件: module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.f

我有一个包含许多子模块的git repo。当我在子模块中提交时,我有一个git钩子,它应该在“超级模块”中提交。不幸的是,post-commit钩子中的提交失败,因为“超级模块”似乎无法检测其子模块中的更改

有没有其他方法可以实现这种行为

我通过Grunt使用
GruntGitHooks
GruntGit
设置了所有这些

下面是我的Grunfile文件:

module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    githooks: {
      all: {
        options: {
            dest: '../../../.git/modules/server/modules/mymodule/hooks'
        },
        'post-commit': 'updateSuperModule'
      }
    },

    gitcommit: {
        all: {
            options: {
                message: 'Updated Submodule',
                cwd: '../../..',
                verbose: true
            },
            files: {
                src: ['.']
            }
        }
    },

    gitpush: {
        all: {
            options: {
                cwd: '../../..',
                verbose: true
            }
        }
    }
  });

  grunt.loadNpmTasks('grunt-githooks');
  grunt.loadNpmTasks('grunt-git');
};
当一个repo的提交(这里是子模块)想要在另一个repo(这里是父repo,在“
。/../../..
”中)中执行git操作时,更改文件夹是不够的

您需要先取消设置GIT\u DIR,然后执行GIT命令()

如果没有,则status或add操作将在子模块的上下文中运行(该子模块刚刚有一个新的提交,并且具有干净的状态)