On the server I have bare repository which is origin for development process and to simplify deployment to QA environment.
So in post-receive
it simply does
As I explain in "checkout only one file from git", you cannot checkout just one file without cloning or fetching first.
But you git show that file, which means you can dump its content into a /another/path./deploy.sh
file, and execute that file.
git-show HEAD:full/repo/path/to/deploy.sh > /another/path./deploy.sh
/another/path./deploy.sh
Since you execute that from a post-receive hook, the git-show will show the latest version of the deploy.sh
file.
The other alternative would be try
GIT_WORK_TREE=$SOURCE_PATH git checkout -- path/to/deploy.sh
And checkout only that file, directly in your working tree.
The '--
' help the git command to understand it is a file, not another parameter like a tag or a named branch.
From the OP AlexKey's test, it requires that the working tree has been checked out (fully) at least once.