

It’s possible to use the same configuration across all repositories, by using a global git hooks path (as seen here):.Using the filename from the example above, we get: git config commit.template. With open(GIT_COMMIT_TEMPLATE, "w") as file: GIT_COMMIT_TEMPLATE = ".git/.commit-template"īranch_name = pygit2.Repository('.').head.shorthand

For example, if your feature branches names are ISSUE-123/feature/new-awesome-feature, and you want the commit message to be prefixed with the issue key ISSUE-123, then the following script could be used (I prefer Python): #!/usr/bin/env python3
Smartgit configure tools install#
If, like me, your goal is to preload a commit message based on the branch name, you can use a workaround in which a static commit message template is generated dynamically every time the post-checkout git hook is triggered.įirst, install a git post-checkout hook that writes a commit message template based on the branch name. However, since SmartGit 18.2, commit message templates are supported ( SmartGit What's new). Unfortunately, SmartGit does not support pre-commit git hook. Where tmplfile is the file which contains your commit message template including the path there from your git project's root. To set this in Smartgit, go to "Tools">"Open git shell", then type To use a template you must set the commit.template option in git-config. If your preloaded commit message doesn't have anything dynamic or which would require a shell script to work out, a template may be the more appropriate route. Git hooks are more versatile than templates. git/hooks directory should give you a good start on writing your own.

( see My post and the two older posts to which it refers )Ĭommit-msg will also allow you to modify the commit message, but does so after the user has sent the messages. Unfortunately Smartgit does not support this hook. Prepare-commit-msg is probably the better suited to your purposes as it allows you to pre-fill the commit message before the user sees it. There are 2 hooks which may be of interest to you:
