> Ok, so using GIT_TRACE and GIT_TRACE_STATUS and doing some debugging I > understand the cause of the bug. When using the alias, > the GIT_DIR environment is set to the bar module: > GIT_DIR=/tmp/test/foo/.git/modules/bar > and is exported. > > That's explain why in `baz` the status report the status of the `bar` > directory. And looking at setup.c:760 it appears that `set_git_dir` (which set up among other things the GIT_DIR env) is called because we are in a worktree. More precisely: we have discovered a git dir (a git file), so we call setup_discovered_git_dir, which itself calls setup_explicit_git_dir because we are in a work tree environment. And set_up_explicit_git_dir calls set_git_dir. So I don't know what's the proper way to fix this. Keep track when we add ourselves the GIT_DIR rather than when it is already provided and remove it before executing a shell alias? Don't run the full configuration setup when we are executing a shell alias anyway? I am adding Nguyễn Thái Ngọc Duy to the discussion (I hope this is the proper etiquette). Best regards, Damien