From: Junio C Hamano Date: Mon, 28 May 2018 02:45:19 GMT Subject: Re: git rebase -i --exec and changing directory Message-ID: In-Reply-To: <3465c994-3917-cd45-bb8e-d1121f60bfb4@talktalk.net> Phillip Wood writes: > I tried your recipe and got the same result as you. However I think it > could be a problem with 'git status' rather than 'git rebase > --exec'. If I run your recipe in /tmp/a and do > > cd dir > GIT_DIR=/tmp/a/.git git status > > I get the same result as when running 'git status' from 'git rebase > --exec' So I think the problem might have something to do with GIT_DIR > being set in the environment when 'git status' is run Yup. When GIT_DIR environment variable appears without GIT_WORKING_TREE, "git" assumes that you are starting it at the root level of the working tree. In your example, if there is README at the top-level but dir/README is not there, "status" would report that you removed it. You can unset GIT_DIR in your --exec script if you know that Git would find the right repository when run from your script.