Run "git" on remote server with drush alias I would like to launch git commands, on my production server, from my pc.
The document root of the production application is a clone of the git repository.

On prod, on sites/all/drush/drushrc.php I've add this line:

&lt;?php

// Drush aliases
$options['shell-aliases']['git-status'] = '!git status';


If I login on production and I execute "git status", everything works.

If I try to execute, from my pc "drush @mysite.prod git-status" I obtain:

fatal: Not a git repository (or any of the parent directories): .git
Command git status failed.


Note that if I try to run "drush @mysite.local git-status", works (and my local copy is like the production copy, the document root is the clone of git repository).

What's wrong?
Document root directory declared on my alias is right (other commons drush commands work) and is a checkout of git repository.

Thanks.
This works just fine for me on both the 6.x and master branches of Drush, and on the 6.2.0 release.  So, your first step would be to try with the latest versions, and see if it works.  If that doesn't fix your problem, try running your command again using the -v flag to get more verbose output.  You will see something like this:

$ drush -v @mysite.prod git-status
Loaded alias @server.xxxxxxxxxxx from file                              [notice]
/home/ga/local/config/drush-aliases/server.aliases.drushrc.php
Loaded alias @mysite.prod from file                                     [notice]
/home/ga/local/config/drush-aliases/mysite.aliases.drushrc.php
Include /home/ga/local/drupal/drush_extensions                          [notice]
Include /home/ga/.drush                                                 [notice]
Calling proc_open(ssh -o PasswordAuthentication=no webuser@myserver.com 'cd /srv/www/myserver.com/htdocs &amp;&amp; git status');
# On branch master
# Untracked files:
#   (use "git add &lt;file&gt;..." to include in what will be committed)
#
#   ../xxxxx.txt
nothing added to commit but untracked files present (use "git add" to track)
Command dispatch complete                                               [notice]


Try running the command inside of "proc_open(...)" from the shell, and see if it behaves the same way.  Adjust the ssh options until it works right.  Then, set $options['ssh-options'] to adjust.

NOTE:

If you want to do something like this without defining a shell alias, the following should also work:

drush @mysite.prod ssh git status