Hackernoon logoUsing GitHub as a team: the holy grail of commit messages by@tom.writer89

Using GitHub as a team: the holy grail of commit messages

Thomas William Hacker Noon profile picture

@tom.writer89Thomas William

Using GitHub with a team is not as easy as it sounds. In this article, I’ll tell you about one tool I’ve come to know during my team projects — gitmojis. It really helped me along the way.

First things first — commit message

Each commit message consists of three components: header, body, and footer.

The header is required, and body and footer are optional.

The header includes type(required), scope(optional), and subject(required).

  • type The category used to describe the commit is only allowed to use the following 7 identifiers:
  • feat: new features
  • fix: patching bugs
  • docs:documentation
  • style: format (does not affect the movement of the code)
  • refactor: Refactoring (neither new features nor code changes to fix bugs)
  • test: increase the test
  • chore: Changes to the build process
  • scope The range used to describe the impact of the commit, such as the data layer, the control layer, view layer, etc., varies from project to project.
  • subject Is a short description of the purpose of the commit, no more than 50 characters.

Interestingly enough, commit messages can contain emojis too, which can greatly improve on the clarity and structure of the project history. Try it yourself — put the emoji code at the start of the commit message, push the changes to your GitHub or Bitbucket repository and you’ll see the emoji, as shown in the image below.


What is Gitmoji?

Gitmoji is an emoji guide for GitHub commit messages. This not only has the purpose of making the history look more hip, but you can now use the emojis to tag and structure changes to the project. Of course, this only works if all developers are on the same page in the meaning of the same emojis.


How to use Gitmoji?

To use gitmojis from the command line you’ll need to install gitmoji-cli. Gitmoji-cli helps you to search through the gitmoji list.

To install it just run:

$ npm i -g gitmoji-cli

Well done! Now you can easily use a Gitmoji. Get started by running:

$ gitmoji — help
A gitmoji interactive client for using gitmojis on commit messages.
 — init, -i Initialize gitmoji as a commit hook
 — remove, -r Remove a previously initialized commit hook
 — config, -g Setup gitmoji-cli preferences.
 — commit, -c Interactively commit using the prompts
 — list, -l List all the available gitmojis
 — search, -s Search gitmojis
 — version, -v Print gitmoji-cli installed version
 — update, -u Sync emoji list with the repo

Please note, the commit functionality can be used directly or via a commit-hook.

In the first case, start the interactive commit client, to auto-generate your commit based on your prompts.

$ gitmoji -c

In the second case, run the init option, add your changes and commit them. After that, the prompts will begin and you commit message will be built.

$ gitmoji -i # this will create the .git/hook/prepare-commit-msg
$ git add .
$ git commit

To find the right gitmoji use specific keywords. For example:

$ gitmoji bug linter -s

Run gitmoji -g to set up some gitmoji-cli preferences, such as the auto git add . feature.

This project is open source, that means everyone can participate, suggest, discuss and add new emojis. All the gitmojis displayed are rendered from a JSON file.

However, emojis should be used discretely when submitting code. Otherwise, they are likely to cause misunderstanding. So the open source gitmoji project defines the emoji specification that should be followed when submitting code on github.

Note the commit format will be following:

Git commit -m ‘:emoji1: :emoji2: theme’

For example, commit for document description will look like:

Git commit -m ‘:memo: documentation description’

Emoji description

🎨 — :art: — Improve code structure / code format

⚡️ — :zap: — Improve performance

🔥 — :fire: — Remove code or file

🐛 — :bug: — Fix bug

🚑 — :ambulance: — Critical patch

✨ — :sparkles: — Introducing new features

📝 — :memo: — Write a document

🚀 — :rocket: — Deployment function

💄 — :lipstick: — Update UI and style files

🎉 — :tada: — Initial submission

✅ — :white_check_mark: — Increase test

🔒 — :lock: — Fix security issues

🍎 — :apple: — Fix problems under macOS

🐧 — :penguin: — Fix problems under Linux

🏁 — :checkered_flag: — Fix problems under Windows

🔖 — :bookmark: — Release/version label

🚨 — :rotating_light: — Remove linter warning

🚧 — :construction: — Work in progress

💚 — :green_heart: — Remove linter warning

🚨 — :rotating_light: — Add CI build system

⬇️ — :arrow_down: — Downgrade dependence

⬆️ — :arrow_up: — Upgrade dependency

👷 — :construction_worker: — Add CI build system

📈 — :chart_with_upwards_trend: — Add an analytics or tracking code

🔨 — :hammer: — Refactoring

➖ — :heavy_minus_sign: — One less dependency

🐳 — :whale: — Docker-related work

➕ — :heavy_plus_sign: — Add a dependency

🔧 — :wrench: — Modify configuration file

🌐 — :globe_with_meridians: — Internationalization and localization

✏️ — :pencil2: — Fix typo

💩 — :hankey: — Write error codes that need improvement

From now on every git commit pops up the gitmoji dialog and before you can write your title you will need to pick a gitmoji first.

Note: If you use Windows, some emoji will not display properly.

Thanks for reading! Feel free to reach out to me if you have something to say!



Join Hacker Noon

Create your free account to unlock your custom reading experience.