
Git and Visual Studio Code: Avoid Commit Text
If you want a quick solution to save you from typing commit messages manually every time while working on Visual Studio Code, then there indeed is a solution that may sound extremely appealing: defining a global commit template. But before carrying out this solution, let's read about both the process and the professional impact of this action.
Using the Global Template
In order to start a commit template that removes the unnecessary request for personal messages, the process is very simple. Start with making a file called .gitmessage.txt
in the root of your project directory. In the file, add an overall message such as 'UPDATE' or any other string you want to use as the default.
Once the file has been prepared, open up the terminal or command line and run the following command:
git config --global commit.template .gitmessage.txt
This instructs Git to utilize the contents of the specified file as the default commit message for all commits made within each repository on the system.
Note that the file path should be absolute when a global configuration is used. If you would prefer to use a local configuration for a specific repository, you can omit the --global
option and provide a path to the repository root relative to the current directory.
Why This Solution Is Problematic
Though this configuration may look like a bright example for speeding up your development cycle, it is actually a bad practice compared to the original practices of source code management and professional collaboration.
Git's version control system was designed with a very specific intention of keeping a rich and meaningful history of the changes made to the code. Commit messages are not bureaucratic form filling, but the living documentation for the project, its narrative history of how the software came to be what it is.
If you send a blanket message such as 'UPDATE' to all commits, you're essentially surrendering one of the best things that developers possess: the ability to comment on the environment and rationale behind each change. Doing so turns project history into a dry and worthless set, and it becomes painfully frustrating for anyone (including your future self) to determine what changed, when, and why.
The Impact on Collaboration between Teams
Having generic commit messages is worse still in an integrated development environment. Members of a team that has a common code base appreciate an unintelligible history in which every change is made to look like the others. It makes it practically impossible to readily point out individual changes, track where bugs originate, or even be aware of how certain features have progressed.
This is particularly tragic when rolling back or debugging. If there are not good commit messages, reversing and locating the broken commit is a task of digital archaeology in the case that one must go through all of the changes manually in order to know what was in it.
Best Practices for Professional Commit Messages
Several conventions and standards for writing a good commit message have been proposed between developers over the years. Most widely used in the list is the 'Conventional Commits' convention where messages are written with the type of change, an optional scope, and a summary.
A good commit message should start with a short subject line, preferably no more than 50 characters in length, describing the change. This should be followed by an empty line and, where appropriate, another descriptive line detailing the purpose of the change, bug that's fixed, or feature added.
The imperative verb use in the subject line is prescriptive. More detailed sentences such as 'Adds email validation' or 'Resolves bug in tax calculation' are far superior to a bland 'UPDATE' and give an instant sense of the change.
Other Tools to Improve Efficiency
If your main concern is the speed of commit execution, there are several more professional alternatives to the generic template. Visual Studio Code itself offers several extensions that can simplify the writing of commit messages without compromising the quality of your documentation.
Extensions such as ‘Conventional Commits’ or ‘GitMoji’ provide structured templates and automatic suggestions that maintain message consistency while speeding up the writing process.
These tools give you the best of both worlds: quote quality and command efficiency.
One heavy-hitter strategy is to use custom Git aliases that combine normal commands with flexible templates. Instead of using a rigid message, you can employ aliases that still require some but helpful input.
The Hidden Cost of Documentation Laziness
The urge to commit generic messages most times comes from the thought that documenting changes is something borrowed from programming and it is time-consuming. This short-term thinking completely disregards the long-term cost of doing so.
A history of commits that is uninformative makes a codebase more laborious. Time apparently saved during coding is doubled later in debugging, refactoring, or training new coders. Without the history about why something is done can make routine operations take the form of time-spending and complex detective work.
Impact on Professional Growth
From a career perspective, the practice of committing with fuzzy commit messages can actually go against your professional development as a coder. Having the ability to articulate code changes well is something that speaks volumes about your professionalism and care for detail.
During code reviews, performance reviews or job interviews, your commit history state of mind will typically reflect how professional a programmer is. The tidiness of a commit message in a project portfolio reflects not only technical competence but also team collaboration skills and organizational skills.
Methods of Forming Good Habits
The transition from boilerplate commit messages to informative documentation entails the use of efficient methodologies that are easy to employ and service. A useful approach is to consider the commit message prior to coding, describing it as a point of reference in an effort to stay focused on exactly the change that you are going to introduce.
Having a sequence of tiny, atomic commits where one commit is dedicated to one logical change makes it only logical to write descriptive messages. When each commit is an independent unit of work, explaining its purpose is natural rather than an artistic exercise.
Better Git Configurations
Rather than initializing a general template, attempt to use Git configurations that maximize productivity for the cost of minimal or no quality. Pre-commit hook configurations can automatically inspect code quality and custom editors can offer dynamic templates that adapt based on the type of change detected.
By means of the enforcement of tools such as Commitizen, writing committing messages can be made an officialized and guided process with minimal cognitive overhead and high documentation quality.
Global Git configuration must be pointed towards things that actually enhance the user experience: correct identity setup, editor setting of preference, useful aliases, and correct line-ending setup.
Invest in the Future of Your Code
Although technically possible to set up a global commit template using generic messages, it is a prime example of how premature optimization will lead to a worse place in the future.
It would be a really bad idea to do that.
Good commit messages are not a slowing down of productivity, but an investment in the long-term health and professionalism of your project. Like with any professional craft, it's something that becomes second nature through practice and discipline, but the payoff in the long term well outweighs the initial time and effort.
The next time you are going to do it with 'UPDATE', take a deep breath and think about what you are actually telling your future self and your other developers. Your future self will thank you for the extra few seconds that you spend typing useful comments that not only make the code run, but also make the code readable and maintainable in the long run.