Re: executing git from a non git directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patrick Aljord <patcito@xxxxxxxxx> wrote:
> I would like to check it from another direcory, I tried the following 
> command:
> 
> $ git --git-dir=/path/to/my_git_dir status
> 
> and
> 
> $ GIT_DIR='/path/to/my_git_dir' && git status

These are actually the same two commands.  The --git-dir option
just means "set GIT_DIR before calling the real command".

However, there are two problems here...
 
> but in both cases I get this error:
> fatal: Not a git repository: '/path/to/my_git_dir'

Right.  That's problem number 1.  /path/to/my_git_dir is probably
not actually your Git repository.  The git repository is actually in
".git", so you really need to use:

  $ git --git-dir=/path/to/my_git_dir/.git status

However, problem number 2 is that status requires a working
directory.  Setting GIT_DIR explicitly like this tells git that
you don't have a working directory present.  So status won't work.

> yet when I do "$ cd /path/to/my_git_dir && git status" I do get the results.

That's what you have to do if you want to run git-status.  Or use
a subshell as that won't change your current working directory:

  $ (cd /path/to/my_git_dir && git status)

-- 
Shawn.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux