Hooking the Test into Git: Working of Git
Get to know how to hook a test into Git.
We'll cover the following
Create scripts
Let’s make two simple scripts to show how git hooks work. The first one will be named .git/hooks/pre-commit
. Do not include the .sample
suffix or any other suffix. In the file, add these lines:
#!/usr/bin/env python
print('Hello from pre-commit')
Make a similar file with a different string and save it as .git/hooks/pre-push
. Then make the files executable by entering the following command in the .git/hooks
directory:
$ chmod +x .git/hooks/pre-commit .git/hooks/pre-push
Add and commit a file
If we now update any file, add it, and commit it to the repository, we should see something like:
Get hands-on with 1400+ tech skills courses.