场景:将source添加到git仓库,hexo server报错
INFO Validating config
INFO Start processing
INFO Hexo is running at http://localhost:5555/ . Press Ctrl+C to stop.
Unhandled rejection WarehouseError: ID `source/.git/logs/refs/heads/main` has been used
at new WarehouseError (D:\GitHub\hexo\pagesHexo2023\node_modules\warehouse\lib\error.js:14:11)
at _Model._insertOne (D:\GitHub\hexo\pagesHexo2023\node_modules\warehouse\lib\model.js:153:29)
at D:\GitHub\hexo\pagesHexo2023\node_modules\warehouse\lib\model.js:179:63
at tryCatcher (D:\GitHub\hexo\pagesHexo2023\node_modules\bluebird\js\release\util.js:16:23)
at D:\GitHub\hexo\pagesHexo2023\node_modules\bluebird\js\release\using.js:185:26
at tryCatcher (D:\GitHub\hexo\pagesHexo2023\node_modules\bluebird\js\release\util.js:16:23)
将.git和README.md分别加入忽略列表
打开配置文件 _config.yml
找到忽略配置 skip_render
添加: [source/.git/**, 'source/README.md']
结果举例:
# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render: [source/.git/**, 'source/README.md']
参考:https://blog.csdn.net/x851288986/article/details/102548839