Hook scripts are useful for identifying simple issues before submission to code review or committing.
Imagine you want to run some tests before committing your changes locally.
You can use a pre-commit script, thanks to git hooks!
Let's see a practical example.
Example
This a simple project in which we have initialized a git repository.
If you list the content of the root directory of the project you can see a .git directory, like this:
The .git directory structure is the following:
In our example, we want to run a pre-commit script so that git commit can't be executed if all the conditions specified in that are not satisfied.
pre-commit.sample contains just a sample, you can substitute it with your
own code. Rename it as pre-commit to enable it.
For our example we simply do this:
thanks for posting this content, checkout my software testing course in pune
ReplyDelete