我有一个git回购,其中包含许多子模块。当我在子模块中提交时,我有一个git钩子,它应该在“超级模块”中提交。不幸的是,后提交挂钩中的提交失败了,因为“超级模块”似乎无法检测到其子模块中的更改。
还有其他方法可以让我做到这一点吗?
所有这些都是通过Grunt使用grunt-githooks和grunt-git设置的。
下面是我的档案:
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');
};发布于 2014-07-10 06:41:32
当回购的提交(这里是子模块)想要在另一个回购中执行git操作(这里是父回购,在“../../..”中)时,仅更改文件夹是不够的。
您需要首先取消设置GIT_DIR,然后执行git命令(就像这个钩子)。
如果没有,状态或添加操作将在子模块的上下文中运行(该子模块刚刚进行了新的提交,并具有干净的状态)。
https://stackoverflow.com/questions/24666936
复制相似问题