hexo+git+阿里云本地使用出现的问题笔记

本文介绍了使用Hexo搭建博客过程中遇到的常见问题及其解决方案,包括部署器未找到、生成及部署过程中的错误提示、远程仓库权限问题等,并提供详细的步骤指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本地问题:
问题1:
$ hexo d
ERROR Deployer not found: git

解决:
npm install --save hexo-deployer-git

问题2:
/d/mybolg/first
$ …/node_modules/.bin/hexo generate -d
INFO Start processing
INFO Files loaded in 87 ms
INFO 0 files generated in 208 ms
INFO Deploying: git
INFO Setting up Git deployment…
Initialized empty Git repository in D:/mybolg/first/.deploy_git/.git/
Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name “Your Name”
to set your account’s default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address
FATAL Something’s wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess. (D:\mybolg\first\node_modules\hexo-util\lib\spawn.js:52:19)
at ChildProcess.emit (events.js:198:13)
at ChildProcess.cp.emit (D:\mybolg\first\node_modules\cross-spawn\lib\enoent.js:40:29)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)

解决:
上面的方法配置的是全局的用户名和邮箱!就是说如果没有单独为项目配置,那提交的所有项目全部都是这个名字和邮箱!不管是公司项目还是github,还是码云!很蛋疼有木有,当码云提交记录上出现我名字的时候我都惊呆了!
单独为项目配置的方法(全局和单独配置都存在的时候会默认使用项目单独配置的):
1.打开项目所在目录,找到隐藏的.git文件夹。注意这个文件夹是隐藏的,显示隐藏出来就行。
2.打开文件夹里的config文件,推荐用nodepad++打开。
3.添加这三行到文件:
[user]
name = XXX(自己的名称)
email = XXXX(邮箱)
当然也可以通过命令行的方式,只需要在 .git 文件夹下。 例如执行如下命令:
git config user.name "xxxxx"

问题3:
…/node_modules/.bin/hexo generate -d 成功后,在阿里云服务器上没有内容:
解决:
需要在服务器上:git --work-tree=/home/www/hexo --git-dir=/home/www/hexo/learngit.git checkout -f
参考:1.https://www.jianshu.com/p/f3e1662ca34f Hexo&Github Blog 搭建
2.https://blog.youkuaiyun.com/a3212/article/details/77099492 手把手教你使用hexo搭建属于你的个人博客

问题4:
**remote: fatal: Unable to create temporary file ‘/home/www/hexo/learngit.git/.git/./objects/pack/tmp_pack_XXXXXX’: Permission denied
fatal: sha1 file ‘’ write error: Broken pipe
error: remote unpack failed: index-pack abnormal exit
error: failed to push some refs to ‘git@hnuscwy.xyz:/home/www/hexo/learngit.git’

解决:
1.首先检查服务器是否创建对应的git仓库,命令:git init ,可发现当前目录多了git文件夹
2.创建好git仓库后,一定要当前仓库给权限:chmod -x .git/
3.再次提交,可提交成功**

问题5:
fatal: ‘/home/www/hexo/learngit.git’ does not appear to be a git repository
fatal: Could not read from remote repository.
注意检查自己的仓库,看下面流程图,是否是按这个流程执行的:

在这里插入图片描述
参考链接:https://segmentfault.com/a/1190000009363890(按照这个流程来执行应该不会有问题)
特别注意:仓库的内容不要自己手动删除
**

### 使用 GitHexoGitHub 搭建个人博客 #### 准备工作 为了成功搭建基于 Hexo 的个人博客,需先完成环境准备。这包括安装 Node.js 及 npm 或 cnpm, 这些工具对于后续操作至关重要。 #### 安装 Hexo 通过命令行工具来全局安装 Hexo 是第一步,在终端中运行如下命令可以实现此目的[^1]: ```bash npm install -g hexo-cli ``` #### 创建本地博客框架 安装完成后,选择一个目录作为博客根目录,并在此处初始化一个新的 Hexo 博客站点: ```bash hexo init blog cd blog ``` #### 设置远程仓库 前往 GitHub 平台创建新的私有或公共存储库用于承载博客内容。之后利用 SSH 密钥对或是 HTTPS 方式关联本地与远端仓库。首次推送前可能需要移除旧有的 `origin` 地址以便重新指定目标地址[^2]: ```bash git remote rm origin # 如果之前已经存在则删除原链接 git remote add origin https://github.com/yourusername/yourrepositoryname.git ``` #### 初始化并提交初始版本 确保所有文件都已加入追踪列表后,执行以下指令以记录更改并将它们推送到 GitHub 上的新分支: ```bash git init git add . git commit -m "Initial commit" git branch -M main git push -u origin main ``` #### 配置部署插件 为了让 Hexo 能够自动同步至 GitHub Pages,还需额外配置名为 `hexo-deployer-git` 的插件。可以通过包管理器快速安装它[^4]: ```bash cnpm install hexo-deployer-git --save ``` 编辑 `_config.yml` 文件中的 deploy 字段指向刚才建立好的 GitHub 仓库路径: ```yaml deploy: type: git repo: https://github.com/yourusername/yourrepositoryname.git branch: gh-pages ``` #### 发布首篇文章 现在可以在 `source/_posts` 下新建 Markdown 文档形式的文章草稿,编写完毕后借助下列命令将其转化为网页格式并上传到服务器上展示给访客们看[^3]: ```bash hexo new post "My First Post" hexo generate hexo deploy ``` 以上就是完整的使用 GitHexoGitHub 来构建静态网站的过程概述。一旦熟悉这些基本流程,就可以进一步探索更多高级功能来自定义自己的在线空间了!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

半点灿烂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值