I'm working with drush & git and I would like to create a custom drush alias to perform a "git pull" action on a remote server.

This is possibile creating a drushrc.php file in drush home directory with this command:

$options['shell-aliases']['git-checkout'] = '!git checkout';

So if I run

drush @mysite.test git-checkout

the system performs a "git checkout" on the test server.

The problem is that I would like to send parameters, like:

$options['shell-aliases']['git-checkout'] = '!git checkout %branch';

and so:

drush @mysite.test git-checkout my_custom_branch

should checkout a specific branch.

Is there a way to do this?


Drush will pass any extra argument in the shell alias to the command. So define the shell alias as:

$options['shell-aliases']['git-checkout'] = '!git checkout';

and simply run

drush @mysite.test git-checkout my_custom_branch
| improve this answer | |
  • Ok you are right :) – arrubiu Aug 7 '13 at 10:15

You can use special shell alias replacements such as {{sitealias-item}}, {{%pathalias-item}} or special {{@target}}, which is replaced with the name of the site alias used.

Or maybe instead of trying to create complex alias, try creating a command file called COMMANDFILE.drush.inc (as already suggested by arrubiu).

| improve this answer | |

Maybe the solution is to create not an alias, but a custom command for drush (here are the instructions).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.