Git calls on another directory

Today I learned that it’s possible to call git commands on a directory/repository other than the one you are currently in. For example to call git status on a repo in /var/app just type:

git --git-dir=/var/app/.git/ --work-tree=/var/app status

I used this in a Python script I’ve been writing at work that automatically checks for updates in a repo and updates the code if there are any. More on that another time.

Leave a Reply

Your email address will not be published. Required fields are marked *