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

GIT_WORK_TREE not set as expected when changing git repository from a script using a git alias

From
GGGabriel Ganne <gabriel.ganne@gmail.com>
Date
Dec 4, 2015, 09:54 UTC
Message-ID
<CAE1CpdRY4fdppx35FyK9fqY8YNzrxvW+WPgqb73mh32tJUF3vQ@mail.gmail.com>
Hi,

Following commit d95138e695d99d32dcad528a2a7974f434c51e79 (since v2.5.1) the following workflow I use seems broken :

I wrote a script to list all git repositories that can be found from where I am, and then call for each repository a given command.

Given the following tree, where "a" & "b" are git repositories, ├── a │ ├── a_file │ └── b │ └── b_file

If I call the script from a git alias, the content of "a" will be listed as untracked files from "b". This is true only when called using the alias.

For example :
$ git all status # called from repository a
 [a]
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        b/
nothing added to commit but untracked files present (use "git add" to track)
 [b]
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
        deleted:    ../b_file
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ../a_file
        ./
no changes added to commit (use "git add" and/or "git commit -a"

I am afraid I did not understand the commit d95138e695d99d32dcad528a2a7974f434c51e79, and do not know how to fix this. I am working around the issue by setting GIT_WORK_TREE manually.

I attached a sample with my example, the script, and the alias I used.
Best regards,

-- Gabriel Ganne

Next: Duy Nguyen
Message 1 of 2 in “GIT_WORK_TREE not set as expected when changing git repository from a script using a git alias”
  1. Gabriel GanneDec 4, 2015
  2. Duy NguyenDec 4, 2015

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.