git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Finding the repository

From
Duy Nguyen <pclouds@gmail.com>
Date
Oct 23, 2013, 08:49 UTC
Message-ID
<CACsJy8DgxpjasroZv4iqTn9JhQ_3r2DD9uEf-xL-uyyPOtWh+A@mail.gmail.com>
In-Reply-To
<5267804b.JaxQnlQ5Cx+By4RS%perryh@pluto.rain.com>
On Wed, Oct 23, 2013 at 2:52 PM, Perry Hutchison <perryh@pluto.rain.com> wrote:
Show 18 quoted lines
> At least in version 1.7.0.4, it seems git does not like being run
> from outside the repository, even if the file(s) being operated
> on are inside the repository, unless it is given a pointer to the
> repository via the --git-dir= option or the GIT_DIR enironment
> variable.
>
> For example, suppose /foo/bar is a local repository and baz.c is a
> file in the outermost directory that I want to remove.  This works:
>
>   $ cd /foo/bar
>   $ git rm baz.c
>
> but this, which intuitively should mean exactly the same thing,
> fails:
>
>   $ cd /foo
>   $ git rm bar/baz.c
>   fatal: Not a git repository (or any of the parent directories): .git

I share your pain. In my case I hate to go inside a directory just to grep something. In my opinion git should be flexible and work at least in unambiguous cases. But it's not easy to determine ambiguity here, especially when the repo finding code does not know anything about "bar/barz.c" (is it a pathname or an argument to an option?). There are more cases to consider, like what if you do "git rm bar/baz.c and rab/zab.c" where bar and rab are two different repositories.. And the setup code is not exactly easy to add these stuff in..

-- 
Duy
Previous: Perry HutchisonNext: Perry Hutchison
Message 2 of 5 in “Finding the repository”
  1. Perry HutchisonOct 23, 2013
  2. Duy NguyenOct 23, 2013
  3. Perry HutchisonOct 24, 2013
  4. Duy NguyenOct 24, 2013
  5. Phil HordOct 25, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.