I have recently started using Microsoft's open-source Visual Studio Code IDE for developing web projects, shifting from Eclipse. I find VSCode highly intuitive and very simple to use.
But one feature I miss in VSCode is that the IDE's inability to remember commit messages (or have I not explored enough?!). Unlike Eclipse, which populates a dropdown list of historical commit messages, we have to manually enter commit messages in VSCode every time we commit our changes.
Is there any VSCode extension available for this purpose?
Can I make any entry in settings.json
so that older commit messages
are retrieved automatically?
Any help would be highly appreciated.
VSCode 1.51 (Oct. 2020) does have a similar feature:
Source Control input box saves commit message history
This addresses a feature request to navigate SCM commit history.
Press
kb(scm.viewPreviousCommit)
andkb(scm.viewNextCommit)
to display the prior and next commits, respectively.
To move directly to the first and last position of the input box, press Alt in conjunction with the corresponding arrow key.Build off of past commit messages and look back in the history without losing your drafted message.
No need for a separate extension or something like that. Git can handle this via commit templates and VSCode supports them already.
For example, assuming you have a unix-like and are in the root of your repository:
echo "My fancy commit message" > .mycommitmsg.txt
git config --local commit.template .mycommitmsg.txt
From there, VSC will automatically use the content of .mycommitmsg.txt.
Second step is to fill this message file with the content of your last commit. That can be achieved with Git hooks, in your case you want the post-commit hook.
Create/edit the file .git/hooks/post-commit
with the following content:
#!/bin/sh
printf "`git log -1 --pretty=%s`" > .gitmessage.txt
Don't forget to make it executable:
chmod +x .git/hooks/post-commit
From there, everything should work as you described. The post-commit hook will automatically fill the message file with the content of your last message and VSC uses the new message as soon as you commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With