1

I know that I can do this:

git --git-dir="Z:/www/proj/web/test/sample-repo-cloned/.git" status

However, the problem is that the command is run from proj folder, which means that all files that are located before sample-repo-cloned will also be taken into account.

Is there a way to run this command under the scope of sample-repo-cloned folder?

Tower
  • 98,741
  • 129
  • 357
  • 507

2 Answers2

2

You should be able to specify the working tree as well as the git directory:

--work-tree

Ie:

git --work-tree="Z:/www/proj/web/test/sample-repo-cloned/" --git-dir="Z:/www/proj/web/test/sample-repo-cloned/.git"  status

The result should be local to the working tree root directory.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Just a note that not all commands are consistent with adhering to these git level options. Stash is one that comes to mind. It doesn't seem to work or at least in certain cases perhaps with relative paths... – Adam Dymitruk Oct 07 '11 at 18:51
  • Cheers :) .. code around those commands takes a different path. Not as easy to fix as I thought. Maybe this weekend... – Adam Dymitruk Oct 07 '11 at 19:09
1

What's wrong with (cd Z:/www/proj/web/test/sample-repo-cloned ; git status) ??

Stefan Näwe
  • 3,040
  • 1
  • 18
  • 19