Skip to content

Instantly share code, notes, and snippets.

@fatorx
Created December 21, 2016 17:11
Show Gist options
  • Save fatorx/8a4edbb09b574b8b4182df4c1184ee67 to your computer and use it in GitHub Desktop.
Save fatorx/8a4edbb09b574b8b4182df4c1184ee67 to your computer and use it in GitHub Desktop.
Git Hooks + PHP
Para executar um script php em um hook do git, basta seguir alguns passos.
Por exemplo, para utilizar o hook pre-commit:
- Criar ou editar o arquivo pre-commit na pasta de .git/hooks
- Criar o arquivo pre-commit.php na pasta de .git/hooks
- Adicionar a seguinte linha para o arquivo:
php .git/hooks/pre-commit.php
- No arquivo pre-commit.php, basta adicionar ações:
<?php
mkdir('templates');
unlink('cache/file.cache');
No caso desse hook, antes de executar um commit o script PHP criar uma pasta e deleta um arquivo de cache.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment