这篇文章属于本人参考诸多博客、教程、文档等资料,所撰写的「玩转Git/GitHub」系列文章之一,将随着时间不断修改完善,目的在于为读者提供有关Git/GitHub使用的大部分参考信息。由于内容随时可能发生更新变动,欢迎关注和收藏玩转Git/GitHub系列文章目录以作备忘。
1. 为什么要使用emoji
不经意发现大佬的GitHub上,Git的提交信息竟然有emoji前缀,相当鹤立鸡群、别具一格,感觉挺有趣的,就想着自己也使用一番。个人认为这样做有三点好处,后两点尤为重要:
- emoji比较呆萌,能美化提交记录和GitHub页面;
- emoji作为标签,能很好的对提交记录分门别类,方便整理;
- emoji蕴含的丰富语义和情绪,能提高提交信息的可读性、可理解性,增强提交历史的阅读体验。
一个示例如下所示,提交新内容,更新属性、贡献者、证明,消除Bug等等,各有各的emoji:
2. emoji来源、用法和个人统一规范
这些emoji来自哪里?有什么统一规范来避免误解吗?有的,像https://gitmoji.dev/上就整理了一套emoji及其用法(如想下载,可见这篇文章),https://www.webfx.com/tools/emoji-cheat-sheet/上的表情更多。用法也很简单,在 git commit
时如下书写提交信息,用 :smile:
来插入一个笑脸emoji:
$ git commit -m ":smile:表示一个笑脸"
除了在Git提交时使用,我们还可以在 README.md
和GitHub Wiki中直接使用emoji。这里整理和列出要使用的emoji,日后会慢慢增加或修改:
# ====常用颜文字====
# 🎉 :tada: Begin a project. 开始一个项目
# 🚧 :construction: Work in progress. 工作进行中
# ✨ :sparkles: Introduce new features. 添加新功能
# 📝 :memo: Add or update documentation. 增加或更新文档
# 🔧 :wrench: Add or update configuration files. 增加/更新配置文件
# 💄 :lipstick: Add or update the UI and style files. 增加/更新UI和样式文件
# 💡 :bulb: Add or update comments in source code. 增加/更新源代码中的注释
# 🚚 :truck: Move or rename resources (e.g.: files, paths, routes). 移动/重命名文件/路径
# 🔥 :fire: Remove code or files. 移除代码/文件
# 🐛 :bug: Fix a bug. 修复bug
# 🚑️ :ambulance: Critical hotfix. 紧急修复
# ⏪️ :rewind: Revert changes. 回退
# ✏️ :pencil2: Fix typos. 修改错别字
# 🔀 :twisted_rightwards_arrows: Merge branches. 合并分支
# ⚡️ :zap: Improve performance. 性能优化
# 🎨 :art: Improve structure / format of the code. 改进代码结构或格式
# ✅ :white_check_mark: Add, update, or pass tests. 增加/更新测试用例
# 📦️ :package: Add or update compiled files or packages. 增加/更新编译后文件/包
# 🙈 :see_no_evil: Add or update a .gitignore file. 增加/更新.gitignore文件
# 📄 :page_facing_up: Add or update license. 增加/更新LICENSE
# 🔊 :loud_sound: Add or update logs. 增加/更新日志
# 🔇 :mute: Remove logs. 移除日志