0%

2021-11-27 解决 commitizen/cz-cli 全局配置问题

2021-11-27 解决 commitizen/cz-cli 全局配置问题

commitizen/cz-cli:https://github.com/commitizen/cz-cli

最近换了新的电脑,然后重装了 commitizen/cz-cli ,结果发现不像以前那样可以在任意目录使用 git cz 指令了,会变成 git commit ,在重新翻阅官方文档之后,发现了解决措施 ,解决方案如下:

Conventional commit messages as a global utility

Install commitizen globally, if you have not already.

1
npm install -g commitizen

Install your preferred commitizen adapter globally (for example cz-conventional-changelog).

1
npm install -g cz-conventional-changelog

Create a .czrc file in your home directory, with path referring to the preferred, globally-installed, commitizen adapter

1
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc

You are all set! Now cd into any git repository and use git cz instead of git commit, and you will find the commitizen prompt.

Pro tip: You can use all the git commit options with git cz. For example: git cz -a.

If your repository is a Node.js project, making it Commitizen friendly is super easy.

If your repository is already Commitizen friendly, the local commitizen adapter will be used, instead of globally installed one.

翻译下来就是在 Home 目录放一个 .czrc 文件即可,内容为

1
2
3
{ 
"path": "cz-conventional-changelog"
}

官方只给出了 Linux 的配置目录,在 ~/下面,Windows 下在 C:\Users\用户名称 下面。

然后就可以全局使用了!

本文作者:草梅友仁
本文地址: https://blog.cmyr.ltd/archives/6d26222d.html
版权声明:转载请注明出处!

坚持原创技术分享,您的支持将鼓励我继续创作!