Git Version Control Cookbook by Kenneth Geisshirt

Git Version Control Cookbook by Kenneth Geisshirt

Author:Kenneth Geisshirt
Language: eng
Format: epub
Tags: COM051000 - COMPUTERS / Programming / General, COM051010 - COMPUTERS / Programming Languages / General, COM056000 - COMPUTERS / Utilities
Publisher: Packt Publishing
Published: 2018-07-25T05:28:18+00:00


#!/bin/bash echo "I refuse to commit" exit 1

Save the file.

Finally, try to commit either something or nothing. Usually, you cannot make a commit that is empty, but with the --allow-empty option, you can create an empty commit as follows:

$ git commit --allow-empty I refuse to commit

As you can see, we get the message we put in the prepare-commit-msg script file. You can check whether or not we have a commit by using git log -1 as follows:

$ git log -1

fatal: your current branch 'master' does not have any commits yet

There is no commit, and we get an error message that we have not seen before. The message has to be there because there is no commit so far in this repository. Before we make further changes to the script, we should know that the prepare-commit-msg hook takes some arguments, depending on the situation. The first argument is always .git/COMMIT_EDITMSG, and the second argument can be merge, commit, squash, or template, depending on the situation. We can use these in the script.

Change the script so that we can reject amending commits as follows:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.