Book Image

Git Version Control Cookbook

By : Aske Olsson, Rasmus Voss
Book Image

Git Version Control Cookbook

By: Aske Olsson, Rasmus Voss

Overview of this book

Table of Contents (19 chapters)
Git Version Control Cookbook
About the Authors
About the Reviewers

Creating a dynamic commit message template

Developers can be encouraged to do the right thing, or developers can be forced to do the right thing; however, in the end, developers need to spend time coding. So, if a good commit message is required, we can use the prepare-commit-msg hook to assist the developer.

In this example, we will create a commit message for developers that contains information about the state of the work area. It will also insert some information from a web page; this could just as well be defect information from Bugzilla for instance.

Getting ready

To start with this exercise, we will not be cloning a repository, but we will be creating one. For doing this, we will be using git init, as shown in the following code. You can use git init <directory> to create a new repository somewhere, or you can also go to a directory and execute git init, and Git will create a repository for you.

$ git init chapter7
Initialized empty Git repository in c:/Users/Rasmus/repos/chapter7...