Git 如何将同一个grunt任务与不同的选项/参数一起使用?

Git 如何将同一个grunt任务与不同的选项/参数一起使用?,git,gruntjs,Git,Gruntjs,我正在使用此处找到的grunt git插件:。该插件定义了一些任务,比如gitpush和gitpull等。下面是gitpush任务的一个示例: grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), //grunt-git tasks gitpush: { task: { options: { remote: 'origin',

我正在使用此处找到的grunt git插件:。该插件定义了一些任务,比如gitpush和gitpull等。下面是gitpush任务的一个示例:

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

    //grunt-git tasks 
    gitpush: {
        task: {
          options: {
              remote: 'origin',
              branch: 'cojo',
        }
      }
    },
分支选项是必需的。它的默认值为空,也就是说,我可以将它留空,因为它不会推送到我所在的当前分支,它根本不会推。有时我想用它来推送到“master”分支,而不是“cojo”分支。我不明白的是(我是Grunt新手)如何以不同的名称再次创建gitpush任务,以便为它提供推送到主任务的选项。在我的脑海里,我想象我想要的是这样的:

 gitpush: {
        task: {
          options: {
              remote: 'origin',
              branch: 'cojo',
        }
      }
    },

 gitpush2: {
        task: {
          options: {
              remote: 'origin',
              branch: 'master',
        }
      }
    },
这显然还不起作用,因为gitpush是GruntGit插件定义的任务的名称。我想到的另一个选择是创建别名任务并向其传递参数,但我不知道这是否可行。

使用不同的目标

gitpush: {
  cojo: {
    options: {
      remote: 'origin',
      branch: 'cojo',
    }
  },
  master: {
    options: {
      remote: 'origin',
      branch: 'master',
    }
  }
}
根据需要使用gitpush:cojo或gitpush:master运行这些命令