個人開発と称してプログラミングの勉強を進めている中で、git commitのコミットメッセージに絵文字(Emoji、gitmoji)をつけて✨ feat: night mode supportみたいに書いてみたいと思ったのですが、入力がめんどくさいので、テンプレートを作ることにしました。
この記事の内容は、以下のリポジトリにも載せています。
コミットテンプレートの例
初心者による初心者のためのおすすめテンプレート例です。
個人開発やサンドボックスで使うことが主な想定です。
対応表や日本語での解説は下にあります。
# ✨ feat:
# └ Add new feature
# 🐞 fix:
# └ Fix a bug (including security fixes)
# 📝 docs:
# └ Add or update documentation
# 💄 ui:
# └ Update UI and style files
# ⚡ perf:
# └ Improve performance
# ♻️ refactor:
# └ Refactor code without changing functionality
# 🎨 style:
# └ Changes that do not affect the meaning of the code
# (white-space, missing semi-colon, etc.)
# 🍱 assets:
# └ Add or update assets
# 🗑️ remove:
# └ Remove code or files
# 🧪 test:
# └ Add or update tests
# 📦 build:
# └ Add or update build system or dependencies
# 🚑 hotfix:
# └ Critical hotfix
# 🔧 chore:
# └ Add or update configuration files or scripts
# 🚧 wip:
# └ Work in progress
# ⏪ revert:
# └ Revert changes
# 🔀 merge:
# └ Merge branches
# 🏷️ release:
# └ Release / Version tags
# 🚀 deploy:
# └ Deploy stuff
# 🎉 init:
# └ Begin a project
テンプレートの設定方法
~/.gitmessage(名前と場所は任意)をtouchで作成する。
touch ~/.gitmessage.txt
作成した.gitmessageに、上のテンプレートをコピーして貼り付ける。
テンプレート内は、好きな順番に変えたり、要らない行を消したり、コメントアウトを追加してもOK。
ファイルを保存し、git configでコミットテンプレートとして設定する。
git config --global commit.template ~/.gitmessage.txt
あとは、git commit するとエディタが開くので、そのエディタで使いたい行のコメントアウトを解除することで使えます。
(関連記事)標準ターミナルでgit commitした際に起動するエディタ(vi)の使い方:
絵文字とprefixの対応ガイド
自己流 & 個人開発向けの構成ですが、なるべくgitmoji公式のガイド↓に準拠するようにしています。
| gitmoji | Prefix | 説明 | 例 |
|---|---|---|---|
✨ :sparkles:
|
feat | 新機能の追加 | ✨ feat: add user profile editing feature |
🐞 :lady_beetle:
|
fix | バグ修正(セキュリティ修正含む) | 🐞 fix: fix display failure |
📝 :memo:
|
docs | ドキュメントの追加・修正 | 📝 docs: add new endpoint to API specification |
💄 :lipstick:
|
ui | UIに関する変更 | 💄 ui: change button color to brand color |
⚡ :zap:
|
perf | パフォーマンス改善 | ⚡ perf: reduce API response time by 300ms |
♻️ :recycle:
|
refactor | 機能変更を伴わないリファクタリング | ♻️ refactor: split authentication process into functions |
🎨 :art:
|
style | コードの意味を変えない整形(インデント、スペースなど) | 🎨 style: unify indentation to 2 spaces |
🍱 :bento:
|
assets | アセットの追加・更新(画像、音声、フォントなど) | 🍱 assets: add new logo image |
🗑️ :wastebasket:
|
remove | ファイル・コード・機能の削除 | 🗑️ remove: delete deprecated API endpoint |
🧪 :test_tube:
|
test | テストの追加・修正 | 🧪 test: add unit tests for user registration API |
📦 :package:
|
build | ビルドシステムや依存関係の変更 | 📦 build: update lodash to v4.17.21 |
🚑 :ambulance:
|
hotfix | 緊急修正 | 🚑 hotfix: fix crash in production environment |
🔧 :wrench:
|
chore | 設定ファイルや開発用スクリプトの変更 | 🔧 chore: update ESLint config and DB init script |
🚧 :construction:
|
wip | 作業途中のコミット | 🚧 wip: implement partial UI for dashboard |
⏪ :rewind:
|
revert | 変更の取り消し | ⏪ revert: revert commit abc123 |
🔀 :twisted_rightwards_arrows:
|
merge | ブランチのマージ | 🔀 merge: merge feature/login into develop |
🏷️ :bookmark:
|
release | バージョンリリース | 🏷️ release: v1.0.0 |
🚀 :rocket:
|
deploy | 本番やステージングへのデプロイ | 🚀 deploy: release v1.2.0 to production |
🎉 :tada:
|
init | プロジェクト初期コミット | 🎉 init: create project structure |
最後に
初心者のため、問題点やアドバイスなど、コメントいただけますと幸いです。