使用dev-分支名#commit-hash可指定Git仓库的特定commit,如composer require monolog/monolog:dev-main#a1b2c3d,需确保分支存在且仓库配置正确,适用于调试或临时依赖,但不应长期使用。

要在 composer.json 中或直接用 composer require 命令指定一个 Git commit hash,格式如下:
包名: dev-分支名#commit-hash
例如,你想安装 monolog/monolog 的某个特定 commit(比如 a1b2c3d),可以运行:
这里说明几点:
如果私有仓库或非标准地址,可能需要在 composer.json 中显式添加 repository:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/user/your-package.git" } ], "require": { "user/your-package": "dev-main#a1b2c3d" } }以上就是composer require时如何指定一个git commit hash作为版本的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号