今天一个可爱的小同事给我分享了一个对项目很有用的Git commit小工具,可以很好的对提交的项目进行管理,方便项目回滚,查看相关push内容和提交分类
commitizen
- 首先在项目中进行全局安装,“徽标键+R”,打开运行,输入
cmd
,打开命令窗口;
npm install -g commitizen
- 进入到项目中,在项目中右键打开
GitBash
,输入以下命令,如果运行失败,可以尝试删除node_modules
依赖,再重新运行以下命令;
commitizen init cz-conventional-changelog
打开package.json
文件,存在下面代码,则可以成功使用commitizen
命令上传项目;
运行成功后在package.json文件中生成
- 上传文件时,如果只上传某一个文件,则输入
git status
查看可上传文件的状态,输入git add 文件名或整个文件路径
;如果全部上传,则直接进行git add .
; - 上传
git commit -m
命令弃用,改成git cz
,返回内容,如下图;
git cz 返回内容,操作键盘可查看更多选择 - 选择好类型后回车,输入上传文件名再回车,记录修改内容(方便以后查看),然后一直回车到结束;
- 输入
git push
回车,提交成功。
分享:git cz 返回内容的含义
前缀 | 英文解释 | 中文解释 |
---|---|---|
feat | A New feature | 新功能 |
fix | A Bug fix | 修复bug |
docs | Documentation only changes | 文档修改 |
style | Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc) | 格式(不影响代码运行的变动) |
refactor | A code change that neither fixes a bug nor adds a feature | 重构 |
perf | A code change that improves performance | 提高性能 |
test | Adding missing tests or correcting existing tests | 添加缺失测试或更正现有测试 |
build | Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) | 依赖的外部资源变化 |
chore | Other changes that don't modify src or test files | 构建过程或辅助工具的变动 |
revert | Reverts a previous commit | 恢复先前的提交 |
今天还get到一个好用的资源管理客户端软件,Sourcetree,直接
clone
项目,可以看到每次push
的记录。