How to make cd, sh and other commands take effect in git-hooks under ubuntu?

want to optimize the workflow, use hook to automatically deploy to the running directory, gitee.

implementation of hook:

git working directory checkout to the running directory no problem:

< H1 >! / bin/bash < / H1 >

git-- work-tree=/www/hooktest checkout-f
but the following command does not take effect
cd / www/hooktest/ & & git add. & & git commit-m test&&git push gitee master

but when I log on to the server, execute it manually. Hook is successful.
that is, when I am in the local push, the cd and git command operations in the hook do not take effect.
it is not applicable for git to execute hook. Orders?
so how does git run hook?

Sep.16,2021

before switching paths, you must first: unset GIT_DIR

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eac836-20df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eac836-20df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?