How to use the command gitmoji (with examples)

How to use the command gitmoji (with examples)

The gitmoji command is an interactive command-line tool that allows users to use emojis on their git commits. This tool adds a bit of fun and expressiveness to commit messages, making them more enjoyable to read and understand. With gitmoji, you can start the commit wizard, initialize or remove the git hook, list all available emojis and their descriptions, search the emoji list for specific keywords, update the cached list of emojis, and configure global preferences. This article will illustrate each of these use cases with examples.

Use case 1: Start the commit wizard

Code:

gitmoji --commit

Motivation:

Starting the commit wizard with gitmoji --commit allows you to interactively choose an emoji for your commit message. This helps add context and emotion to your commits, making them more meaningful and engaging.

Explanation:

The --commit argument triggers the commit wizard, which presents you with a list of available emojis and prompts you to choose one. After selecting an emoji, you will be prompted to enter a commit message.

Example output:

- Choose a gitmoji:
1. ✨  - Introduce new features (code or files)
2. 🐛  - Fix a bug
3. 📚  - Add or update documentation
4. 🌐  - Internationalization and localization
5. ♻️  - Refactor code
6. 🚚  - Move or rename files
7. 🔧  - Update configuration files
8. ⚡️  - Improve performance
9. 🚨  - Fix compiler or linter warnings
10. 🚧  - Work in progress
...
- Enter the commit message: Update README file

Use case 2: Initialize the git hook

Code:

gitmoji --init

Motivation:

Initializing the git hook with gitmoji --init ensures that gitmoji is run every time git commit is executed. This helps you maintain consistent emoji usage across your commits, improving the readability and aesthetics of your commit history.

Explanation:

The --init argument initializes the git hook, which sets up a pre-commit hook that automatically runs gitmoji before each commit. This way, you don’t have to remember to use gitmoji --commit manually.

Example output:

Git hook successfully initialized.

Use case 3: Remove the git hook

Code:

gitmoji --remove

Motivation:

Removing the git hook with gitmoji --remove allows you to stop running gitmoji every time you commit. This is useful if you no longer want to use gitmoji or if you want to temporarily disable the hook.

Explanation:

The --remove argument removes the git hook, disabling the automatic execution of gitmoji before each commit.

Example output:

Git hook successfully removed.

Use case 4: List all available emojis and their descriptions

Code:

gitmoji --list

Motivation:

Listing all available emojis with gitmoji --list allows you to explore the different types of emojis you can use in your commit messages. This is useful if you want to see the complete list or if you need a reminder of what each emoji represents.

Explanation:

The --list argument displays a table with all available emojis and their corresponding descriptions. This helps you choose the most appropriate emoji for your commit message.

Example output:

| Emoji       | Description                               |
| ------------| ----------------------------------------- |
| ✨           | Introduce new features (code or files)     |
| 🐛           | Fix a bug                                 |
| 📚           | Add or update documentation                |
| 🌐           | Internationalization and localization     |
| ♻️           | Refactor code                             |
| 🚚           | Move or rename files                       |
| 🔧           | Update configuration files                 |
| ⚡️           | Improve performance                       |
| 🚨           | Fix compiler or linter warnings            |
| 🚧           | Work in progress                          |
...

Use case 5: Search emoji list for a list of keywords

Code:

gitmoji --search keyword1 keyword2

Motivation:

Searching the emoji list with gitmoji --search allows you to find specific emojis that match given keywords. This is useful when you’re looking for a particular emoji but don’t know its name or number.

Explanation:

The --search argument takes one or more keywords as input and filters the emoji list to show only the emojis that match those keywords. This helps you quickly find the desired emoji for your commit message.

Example output:

Searching for keywords 'documentation', 'update':

| Emoji       | Description                               |
| ------------| ----------------------------------------- |
| 📚           | Add or update documentation                |
| 📝           | Write code comments                       |

Use case 6: Update cached list of emojis from main repository

Code:

gitmoji --update

Motivation:

Updating the cached list of emojis with gitmoji --update ensures that you have the latest emoji options available. This is particularly useful when new emojis are added or existing ones are modified in the main repository.

Explanation:

The --update argument fetches the latest emoji list from the main repository and updates the local cache. This ensures that you have access to the most up-to-date emojis when interacting with gitmoji.

Example output:

Successfully updated the cached list of emojis.

Use case 7: Configure global preferences

Code:

gitmoji --config

Motivation:

Configuring global preferences with gitmoji --config allows you to customize the behavior of gitmoji according to your preferences. This is useful when you want to change certain settings, such as the default emoji or the commit template.

Explanation:

The --config argument presents an interactive configuration menu that allows you to modify various settings. These settings include the default emoji for new commits, the commit template, and the commit message format.

Example output:

Select an option to configure:
1. Default emoji for new commits: [Select]
2. Commit template: None
3. Commit message format: #{number} - {emoji} {description}
...

Conclusion:

The gitmoji command provides a fun and interactive way to incorporate emojis into your git commits. By using the various use cases illustrated in this article, you can enhance the expressiveness and readability of your commit messages. From starting the commit wizard to configuring global preferences, gitmoji offers a wide range of options to make your commits more enjoyable and informative. So go ahead, give your commits a little more personality with gitmoji!

Related Posts

Managing Amazon Lightsail Resources (with examples)

Managing Amazon Lightsail Resources (with examples)

List all virtual private servers, or instances You can list all the virtual private servers (instances) in your Amazon Lightsail account using the get-instances command.

Read More
How to use the command 'vm_stat' (with examples)

How to use the command 'vm_stat' (with examples)

The ‘vm_stat’ command is used to display virtual memory statistics on a Unix-like operating system.

Read More
How to use the command `sdkmanager` (with examples)

How to use the command `sdkmanager` (with examples)

The sdkmanager command is a tool provided by the Android SDK to install, update, and uninstall packages for Android development.

Read More