Mike007 Mike007 - 3 months ago 12
Git Question

Working on git repo without cd into directory

How would I run git commands on a repo when I am not cd'd into that directory?

i.e. git branch /repos/myrepo.git

Answer

--git-dir=<path>

Set the path to the repository. This can also be controlled by setting the GIT_DIR environment variable. It can be an absolute path or relative path to current working directory.

http://www.kernel.org/pub/software/scm/git/docs/git.html

Note that <path> above means the path to the actual git directory (project_dir/.git) not just the project directory (project_dir).

Comments