# BUG: git_work_tree issue with git alias and scripting

1 messages from 2015-09-18 to 2015-09-18. Participants: Tuomo Tanskanen.
Thread: https://gitlist.dev/t/40376

## Tuomo Tanskanen, 2015-09-18 07:33

Subject: BUG: git_work_tree issue with git alias and scripting
Message-ID: <CAE_UwRp7LB0E636u9cOEisMgJi3xApAVPPH_T2Hpkm43DS5F0A@mail.gmail.com>
URL: https://gitlist.dev/e/CAE_UwRp7LB0E636u9cOEisMgJi3xApAVPPH_T2Hpkm43DS5F0A%40mail.gmail.com

```
Hello,

Attached is a simple script exposing a possible bug when git alias is
combined with git commands in script. It should be pretty self-explanatory.
Check what it does and execute it. On my Linux and OSX, both with git 2.5.1
behave the same, ie. git add fails even the file "test" is in $PWD.

Summary: $GIT_WORK_TREE persists in env, and then some git commands operate
on repo in $PWD (like git log), while some others (like git add) operate on
repo in $GIT_WORK_TREE, making it inconsistent and results in very
unexpected results.

Cheers, Tuomo

```
