I have setup path to the template file on my config file, and it works fine when I do basic commit (git add -A . && git commit
):
[commit]
template = .git-commit-template.txt
Instead when I try to squash N-commits, and also add their messages, my commit template does not show up.
=> Is there any way add git template message during squashing last N commits?
The way I squash my last 2 commits with the help of this answer: https://stackoverflow.com/a/5201642/2402577
If you want to start editing the new commit message with a concatenation of the existing commit messages:
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
#!/bin/bash
git reset --soft HEAD~2
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})" # template message does not show up
As alternative when I do following I get the same result:
git reset --hard HEAD~2 && git merge --squash HEAD@{1} && git commit