Git - git-dir does not work in windows

In the hook script for Git, I am trying to run such a command.

see ( git - git-dir not working properly )

git log --name-status --git-dir="C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\CMS\.git" --work-tree="C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\CMS" 

when i run this command i get the following error.

 fatal: Not a git repository (or any of the parent directories): .git 

Is there something wrong with the command I'm using?

+4
source share
2 answers

Since this is a hook script , it will probably use POSIX paths in a bash session, not Windows paths.

 git log --name-status --git-dir='/C/Documents and Settings/user/My Documents/Visual Studio 2008/Projects/CMS/.git' --work-tree='/C/Documents and Settings/user/My Documents/Visual Studio 2008/Projects/CMS' 

From a DOS session (as in the non-hook case), the path might look like this:

 git log --name-status --git-dir='C:/Documents and Settings/user/My Documents/Visual Studio 2008/Projects/CMS/.git' --work-tree='C:/Documents and Settings/user/My Documents/Visual Studio 2008/Projects/CMS' 

Alternative syntax (not tested): "c:\\xxx\\yyy\\..."

+2
source

I recently had this problem on a Mac, the solution for me was to put the directives - git-dir and -work-tree in front of the git subcommand.

So your command will look like this:

 git --git-dir="C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\CMS\.git" --work-tree="C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\CMS" log --name-status 

Hth, it helped.

+7
source

All Articles