Chapter 7. Enhancing Your Daily Work with Git Hooks, Aliases, and Scripts

In this chapter, we will cover the following topics:

  • Using a branch description in the commit message
  • Creating a dynamic commit message
  • Using external information in the commit message
  • Preventing the push of specific commits
  • Configuring and using Git aliases
  • Configuring and using Git scripts
  • Setting up and using a commit template

Introduction

In order to function in a corporate environment, there should be certain prerequisites to the code that is produced. It should be able to compile and pass specific sets of unit tests. There should also be certain documentation in the commit messages, such as references to a bug fix ID or an instance. Most of these are just scripts that are executed, so why not put these items in to the process? In this chapter, you will see some examples of how to transfer data from one location to the commit message before you see the message. You will also learn how you can verify whether you are pushing your code to the right location. Finally, you will see how you can add scripts to Git.

A hook in Git is a script that will be executed on different events, such as pushing, committing, or rebasing. These scripts, if they exit with a non-zero value, cancel the current Git operation. You can find these hook scripts in the .git/hooks folder in any Git clone. If they have the .sample file extension, then they are not active.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset