Last active
December 18, 2023 21:03
-
-
Save dmstern/d02ea41d4b0171ff2f4661daaa3e3f86 to your computer and use it in GitHub Desktop.
Git: pre-fill commit message with Jira Issue Id/title and re-use last commit message (also works with VSCode)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# located in .git/config: | |
# VSCode will use this to prefill the git commit message box. | |
[commit] | |
template = .git/.gitmessage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# .git/hooks/post-checkout | |
# Writes the Jira Id + Jira summary from the recently checked out branch name to the git commit template. | |
######################################################################################################### | |
printf "`git rev-parse --abbrev-ref HEAD | sed 's/-/❤/' | sed -E 's/[-|_]+/ /g' | sed 's/❤/-/'`" > .git/.gitmessage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# .git/hooks/post-commit | |
# re-use last commit message | |
######################################################### | |
printf "`git log -1 --pretty=%s`" > .git/.gitmessage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"key": "ctrl+shift+g u", // Or what ever fits for you | |
"command": "git.restoreCommitTemplate" | |
}, | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment