* executing git from a non git directory
@ 2007-07-22 6:55 Patrick Aljord
2007-07-22 7:07 ` Shawn O. Pearce
2007-07-22 7:11 ` Jeff King
0 siblings, 2 replies; 4+ messages in thread
From: Patrick Aljord @ 2007-07-22 6:55 UTC (permalink / raw
To: git
Hey all,
I have my git directory that is in /path/to/my_git_dir
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
but in both cases I get this error:
fatal: Not a git repository: '/path/to/my_git_dir'
yet when I do "$ cd /path/to/my_git_dir && git status" I do get the results.
Any idea what I'm doing wrong or if there's a way to check a git dir
from a non git dir?
thanx in advance
Pat
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: executing git from a non git directory
2007-07-22 6:55 executing git from a non git directory Patrick Aljord
@ 2007-07-22 7:07 ` Shawn O. Pearce
2007-07-22 7:11 ` Jeff King
1 sibling, 0 replies; 4+ messages in thread
From: Shawn O. Pearce @ 2007-07-22 7:07 UTC (permalink / raw
To: Patrick Aljord; +Cc: git
Patrick Aljord <patcito@gmail.com> 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: executing git from a non git directory
2007-07-22 6:55 executing git from a non git directory Patrick Aljord
2007-07-22 7:07 ` Shawn O. Pearce
@ 2007-07-22 7:11 ` Jeff King
2007-07-22 19:02 ` Patrick Aljord
1 sibling, 1 reply; 4+ messages in thread
From: Jeff King @ 2007-07-22 7:11 UTC (permalink / raw
To: Patrick Aljord; +Cc: git
On Sun, Jul 22, 2007 at 01:55:33AM -0500, Patrick Aljord wrote:
> $ git --git-dir=/path/to/my_git_dir status
>
> and
>
> $ GIT_DIR='/path/to/my_git_dir' && git status
>
> but in both cases I get this error:
> fatal: Not a git repository: '/path/to/my_git_dir'
A git dir is the location where all of the repository information is
stored; it is called '.git' for a directory with a working tree. Is
/path/to/my_git_dir really a git dir, or is it a working directory that
has a '.git' inside it?
If the latter, then you need to specify the .git directory. However,
running 'git-status' won't make any sense then, since you won't be in
the correct working tree (so of course it will look like files have been
removed).
You could do something like "git --dir /path/to/my_git_dir/.git branch"
and it would at least produce sensible results.
> yet when I do "$ cd /path/to/my_git_dir && git status" I do get the results.
Right. That's the way you have to do it in the case of 'status', since
you need your current working directory to be in the right place.
If you are running a very recent git, you can now try:
git --work-tree=/path/to/my_git_dir --git-dir=/path/to/my_git_dir/.git status
which is what you actually want.
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: executing git from a non git directory
2007-07-22 7:11 ` Jeff King
@ 2007-07-22 19:02 ` Patrick Aljord
0 siblings, 0 replies; 4+ messages in thread
From: Patrick Aljord @ 2007-07-22 19:02 UTC (permalink / raw
To: git
ok thanx to both of you Jeff and Shawn for the info.
On 7/22/07, Jeff King <peff@peff.net> wrote:
> git --work-tree=/path/to/my_git_dir --git-dir=/path/to/my_git_dir/.git status
>
> which is what you actually want.
ok, I'm going to try that, thanx.
Pat
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-22 19:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-22 6:55 executing git from a non git directory Patrick Aljord
2007-07-22 7:07 ` Shawn O. Pearce
2007-07-22 7:11 ` Jeff King
2007-07-22 19:02 ` Patrick Aljord
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).