Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When using git add . uses the actual path where you're (incase is a git repo). How would I do for using git add, git commit and git push' outside of the working dir? Likegit add /Users/zad0xsis/my-git-repo`. Can this be achieved? Thanks!

share|improve this question
To clarify, you want to run the add command in a git repository outside of the current working directory? – Scott Keck-Warren Oct 6 '11 at 14:53
exactly, really I want to run git add, git commit and git push on a directory outside the working directory – pmerino Oct 6 '11 at 14:54

This can't be done because git expects everything to be housed under the same repository (directory). If /Users/zad0xsis/my-git-repo is a git repository you will need to cd to that directory and then run push, add, and commit.

share|improve this answer

According to the git docs on my system (git 1.7.6) you can adjust the working directory (where the code resides) using --work-tree or $GIT_WORK_TREE and the repository directory (where the git objects reside) using --git-dir or $GIT_DIR. If that doesn't work you could use a wrapper script, e.g.


cd /desired/path

git "$@"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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