# Impossible to change working directory

3 messages from 2016-09-29 to 2016-10-01. Participants: Sebastian Feldmann, Junio C Hamano, Torsten Bögershausen.
Thread: https://gitlist.dev/t/44189

## Sebastian Feldmann, 2016-09-29 19:30

Subject: Impossible to change working directory
Message-ID: <A99D7D06-8214-4C09-BCB2-E4FCE75FF317@sebastian-feldmann.info>
URL: https://gitlist.dev/e/A99D7D06-8214-4C09-BCB2-E4FCE75FF317%40sebastian-feldmann.info

```
Hi there,

I have a problem executing a pre-commit hook.
The hook script has to change the working directory to work and if I use plain

git commit

it works as expected, the script executes without errors, but if I use

git commit —only file.x file.y

the script fails because changing the current working directory fails.
If I echo the current working directory it always echoes the root repository path

Is this expected behavior?
Thanks for your feedback.

Cheers Sebastian





```

## Junio C Hamano, 2016-09-29 23:24

Subject: Re: Impossible to change working directory
Message-ID: <xmqq37kicmsb.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqq37kicmsb.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <A99D7D06-8214-4C09-BCB2-E4FCE75FF317@sebastian-feldmann.info>

```
Sebastian Feldmann <sf@sebastian-feldmann.info> writes:

> the script fails because changing the current working directory fails.
> If I echo the current working directory it always echoes the root repository path
>
> Is this expected behavior?

Yes, we always go to the top before doing anything.

If you echo environment variables Git may set up for you, what do
you see?  Do you see GIT_PREFIX that you can use to tell where you
came from, or something like that?

```

## Torsten Bögershausen, 2016-10-01 15:34

Subject: Re: Impossible to change working directory
Message-ID: <477492a9-7ff2-59d0-1463-b47694ce66c1@web.de>
URL: https://gitlist.dev/e/477492a9-7ff2-59d0-1463-b47694ce66c1%40web.de
In-Reply-To: <A99D7D06-8214-4C09-BCB2-E4FCE75FF317@sebastian-feldmann.info>

```
On 29.09.16 21:30, Sebastian Feldmann wrote:
> Hi there,
>
> I have a problem executing a pre-commit hook.
> The hook script has to change the working directory to work and if I use plain
>
> git commit
>
> it works as expected, the script executes without errors, but if I use
>
> git commit —only file.x file.y
>
> the script fails because changing the current working directory fails.
> If I echo the current working directory it always echoes the root repository path
>
> Is this expected behavior?
> Thanks for your feedback.
Is there any chance to send us the content of the script ?
(Or a demo example, which doesn't work)


```
