Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git --git-dir not working in windows

Tags:

git

msysgit

In a hook script for Git, I am trying to run a command like this..

please refer to(git --git-dir not working as expected)

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 am getting the following error.

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

Is there any thing wrong in the command I am using?

like image 367
Syam Avatar asked Dec 01 '10 23:12

Syam


2 Answers

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

So, your command would 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 did the trick for me.

like image 99
bloveridge Avatar answered Nov 12 '22 03:11

bloveridge


Since it 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 "not a hook), the path might have looked like:

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\\..."

like image 3
VonC Avatar answered Nov 12 '22 03:11

VonC