In order to extend the functionality of git, I recommend you the concept of hooks. They can be put into your Fetch/Pull/Deploy workflow at any desired level.

The most important thing to keep in mind is that they're just working locally. If you want to provide them on your repository provider (like github.com), you can make use of so-named web hooks.

Hooks are available in every cloned repository by default, being set to inactive (e.g. pre-commit.sample). Active hooks do not have a file extension, hence they are named like post-merge or commit-msg.

You can access all hooks by navigating to <root>/.git/hooks [1].

The usage of hooks is not limited to any OS or GUI Client, you are using git with, as they are run by the git engine and are always executed in a UNIX emulated environment (bash). Nevertheless, i propose you a small list of GUI clients which I have worked with and can recommend.

List of common git GUI Clients (imcomplete and subjective)

All of the mentioned clients offer a free-to-use version, the two latters are open-source anyway.

Example: pre-commit hook

The following snippet is an example for a pre-commit hook.

At the start, git pull is performed on the repository and non-ASCII filenames are allowed.

Basically this hooks checks all staged files against a file name pattern (*.sql), renames them and adds some bits to their content, before staging them again.

The content search and renaming is performed efficiently by the grep command, while using regular expressions.

Potential error messages along with other information are piped to the default error output, which is usually a message box (When using a GUI client), otherwise to the shell.

pre-commit

Hooks within submodules

If your main repository has included submodules and you want to access their hooks, your git folder is still on root level of your file structure. You can find the hooks therefore below <root>/.git/modules/hooks.

Sources

[1] git-scm.com: Customizing git hooks

[2] github.com: Pre-commit hooks won't work with gitHub Desktop

See also

  • Testautomatisierung (Java)

    Viele und gute Testfälle sind eine gute Voraussetzung für eine qualitativ hochwertige Software. Während eines Entwicklungsprozesses sind mit an Sicherheit grenzender Wahrscheinlichkeit jedoch die meisten Methoden, die durch die Testfälle geprüft werden, von Änderungen betroffen. Eine Automatisierung aller Testfälle ist also nicht nur wünschenswert, sondern auch wichtig, um Fehlerfortpflanzung zu vermeiden. In diesem Artikel gehe ich auf die Vorteile und Werkzeuge der Testautomatisierung ein.

  • git
    git is the goal: Installation and management of a Version Control System (VCS)

    I will here drop some thoughts and design recommendations that you should consider when migrating from a formerly used VCS (Version Control System) to a newer one. As I am a fan of the usage of workflow concepts, the periodic workflow scheme will be focused in this article.

  • MMM-RVV English version
    MagicMirror²: Development of the RVV departure monitor

    By developing a departure monitor for the RVV (Regensburger Verkehrsverbund) train and bus system (ÖPNV / public transport), I extended the variety of the modules, offered by the amazing MagicMirror² project. Feel free to install the module to your MagicMirror installation and give me feedback about the behaviour or possible extensions.

Cookies make it easier for us to provide you with our services. With the usage of our services you permit us to use cookies.
Ok