Git newbie here. I want a post commit hook that when run will copy the latest code from the repository to a different server in a new folder. The folder name should be what I wrote in the git commit comment.
Is this possible?
Git newbie here. I want a post commit hook that when run will copy the latest code from the repository to a different server in a new folder. The folder name should be what I wrote in the git commit comment.
Is this possible?
Copyright © 2021 Jogjafile Inc.
Since you don't look so certain as to which hook you need, according to the coments, I'm posting an answer based on post-receive hook. This is a server-side hook that will ran after everything is received in the server, after a push. A post-commit hook would be client-side, and would run after every commit (for more info about git hooks, see https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks).
Assuming a bash script, you can use:
to retrieve the last commit message, and work from there to create your script. It's also possible to retrieve every commit message included in that push, by using:
As for copying it to somewhere else, you can use anything you'd use in other scripts, like scp, rsync... Just clone/update a local copy in a temp dir and sync it to your remote location.