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

Menu