Git: How to run a command on a specific folder

Git Logo

I recently needed to be able to run a regular git task on a folder and I didn't want to have to CD into that folder first. Annoyingly, there didn't seem to be an optional "path" parameter to git remote update, until I looked at the help file for Git.

It's quite simple! All you need to do, to run a git command on an arbitrary path, is this:

$ git --git-dir=/path/to/the/repository remote update

This makes assigning, say, a cron job to regularly update repository which is being used by a tool such as GitList, very easy indeed!