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

2 messages from 2015-12-04 to 2015-12-04. Participants: Gabriel Ganne, Duy Nguyen.
Thread: https://gitlist.dev/t/40931

## Gabriel Ganne, 2015-12-04 09:54

Subject: GIT_WORK_TREE not set as expected when changing git repository from a script using a git alias
Message-ID: <CAE1CpdRY4fdppx35FyK9fqY8YNzrxvW+WPgqb73mh32tJUF3vQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAE1CpdRY4fdppx35FyK9fqY8YNzrxvW%2BWPgqb73mh32tJUF3vQ%40mail.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

```

## Duy Nguyen, 2015-12-04 14:31

Subject: Re: GIT_WORK_TREE not set as expected when changing git repository from a script using a git alias
Message-ID: <CACsJy8BSca7qdxcPojaPEjGwur+Nnsq2KFWsKX4gcVKR2N6e6A@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8BSca7qdxcPojaPEjGwur%2BNnsq2KFWsKX4gcVKR2N6e6A%40mail.gmail.com
In-Reply-To: <CAE1CpdRY4fdppx35FyK9fqY8YNzrxvW+WPgqb73mh32tJUF3vQ@mail.gmail.com>

```
On Fri, Dec 4, 2015 at 10:54 AM, Gabriel Ganne <gabriel.ganne@gmail.com> wrote:
> Hi,
>
> Following commit d95138e695d99d32dcad528a2a7974f434c51e79 (since
> v2.5.1) the following workflow I use seems broken :

You are not the first one bitten [1] by that commit. A fix is being
worked on [2]. Sorry for the trouble.

[1] http://thread.gmane.org/gmane.comp.version-control.git/281608
[2] http://article.gmane.org/gmane.comp.version-control.git/281960
-- 
Duy

```
