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!

Comment Icon

2 Comments

The most recent comment was on Tue, 19th Mar 2013 - 00:00

That is a really cool update. You can also give permissions to folder as well. that's great.

cool site

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <img> <p>
  • You can use BBCode tags in the text. URLs will automatically be converted to links.
  • You can enable syntax highlighting of source code with the following tags: <code>, <pre>, <bash>, <css>, <html>, <js>, <jquery>, <mysql>, <php>. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.