Intro
I recently came across Gitmoji - an emoji guide for your commit messages. It looked fun and thought I would give it a try on some side projects to see if it is a gimmick or if it could be helpful.
What is Gitmoji?
“Gitmoji is an initiative to standardise and explain the use of emojis on GitHub commit messages” Gitmoji docs
I didn’t actually realise you could render emojis in Git commit messages and, if I’m honest, it was never really a feature I thought I had been missing.
You can add emojis to any commit message by using the CLDR Short Name or unicode of the emoji in the commit message text.
For example, git commit -m ":bug: Fixed formatting error on home page"
would render as 🐛 Fixed formatting error on home page
in Github in the commit message summary - cool, right?
Some of the benefits of adding emojis to commit messages are as follows:
- Categorisation - pictures can be easier to identify at a glance, making it easier to find particular commit messages when scanning the commit log
- ‘Picture tells a 1000 words’ - pictograms convey more information in less space, potentially reducing the length of the commit messages
- Fun - emojis make the Git repo more fun and interesting to work with
Ok, I probably made that last point up…
However, the problem arises that you could use many different emojis to convey the same issue.
For example, which bug emoji should you choose for a bug fix? 🐜, 🐝, 🐞, 🦗, 🕷️ and 🐛 are all good options.
Additionally, the meaning of emojis could be interpreted differently by different people. Would all your collaborators instinctively know what you meant by a 🚀 emoji in your commit message - did you ship a new version or optimise a piece of code?
If multiple people are collaborating on the same code repository using emojis, it could get out of hand very quickly and actually make things more confusing, rather than easier to read as initially intended.
Gitmoji aims to bring order to the chaos by providing a standardised list of emojis with descriptions for commonly implemented code changes. Gitmoji also ships with a CLI which can be set up as a git hook to help enforce consistency when creating a new commit message.
Getting started
Installation
The CLI can be installed using using either npm
or brew
. Further information is described in the gitmoji-cli README
.
brew install gitmoji
Usage
Once installed, you can use the commit functionality in two ways. Either via an interactive client to generate a new commit message based on your responses to the prompt, or via a commit-hook which will open the interactive client automatically when writing the commit message.
The interactive client provides some prompts and allows you to select the most appropriate emoji for your commit message from a list.
Client
gitmoji -c
Hook (my preferred option)
# set up hook
gitmoji -i
# run through standard commit workflow
git add .
git commit
So how does this look in a GitHub repo?
I have been playing around with the commit messages in one of my side project repos . I have to say I quite like the extra colour and interest it adds to the messages.
My thoughts
Cons
After playing around with the tool, I have found it quite fun and easy to use, however, I can think of a few issues which might make me think twice before suggesting to colleagues
Counter to its original intention, in my opinion it is harder to read and search than a normal text-only message. Searching for key terms will be harder if those key terms (e.g. deploy, bug etc.) have been replaced by an emoji. As mentioned previously, sometimes it is not always obvious what is meant by a particular emoji. Would you instinctively know what is meant by a ⚡ emoji when scanning through the repo?
It still requires descriptive commit messages. An emoji is never clear enough on its own and still requires a description of the changes that have been made. Why complicate things with an emoji? Just write good commit messages in the first place.
It could tempt bad habits and make people less explicit in their messages. It is very tempting to reduce the amount of information in your commit message because you believe the emoji conveys enough.
Finally, emojis are not compatible on all terminals (looking at you Windows 🧐) which could make it difficult for some collaborators. Not all terminals support the rendering of emojis which makes the CLI difficult to use. Windows in particular does not seem to support rendering emojis in their terminal applications. I couldn’t get the emojis to render in PowerShell or WSL, so had to use my MacBook instead.
Pros
However, there are some pros.
The CLI reduces friction and enforces consistency if you do want to use emojis. It does a good job of clearly describing each emoji which will help with consistency in the repository.
Attaching a single emoji to a message encourages single changes and separation of commits. As you can only add one emoji to the start of the commit message it encourages you to make sure you are only making one change to the code on each commit. E.g. not mixing a bugfix with a code optimisation in different parts of the code base.
Conclusion
I had great fun playing with the Gitmoji tool and would recommend you try it out on some side projects.
It is easy to install and use (provided you are on linux/macos) and helps with consistency in git commit messages. While I can see the benefits and will continue to use it on some of my side projects, I think for production projects with multiple collaborators it makes sense to keep things simple and use standard commit identifiers instead of emojis!
Happy coding!
Resources
Further Reading
- Automate your Macbook Development Environment Setup with Brewfile
- Five Tips to Elevate the Readability of your Python Code
- SQL-like Window Functions in Pandas
- Matplotlib: Plotting Subplots in a Loop
- Improve Code Quality with Pre-commit
- Which Python String Formatting Method Should You Be Using in Your Data Science Project