HEXO一键部署Git多账户配置

773 阅读2分钟

前言

碰到一个应用场景,我手下有两个域名,想利用GitHub Pages部署两个网站,于是注册了两个GitHub的账号,但在使用HEXO进行一键部署的时候,发现两个GitHub项目中的提交人均显示为相同的一个账户,这可就不太好了,毕竟我不太想让大家知道我两个GitHub账号之间的关联性。

  • 为什么均显示相同的账户呢?是因为使用了Git的全局配置吗?可以在~/.gitconfig文件查看配置,也可以使用命令git config --list查看。还是因为你在项目文件夹的配置中没指明?答案就是没指定账户于是就默认全局账户!!!我们解决问题要回归本源,这里的HEXO一键部署使用的是插件hexo-deployer-git,点进去看就知道可以配置很多东西了,而不是HEXO官方文档里面少得可怜的配置项,总的来说该插件功能强大,可以满足我现在的需求。
  • 怎么解决这一问题呢?在配置文件中做一些更改即可。不需要在Git层面进行配置。

本来想着参考这篇文章,写一个《Git多账户配置:根据项目配置不同的账号》,其实完全不需要!!!(但也算是长知识了)

配置

# You can use this:
deploy:
  type: git
  repo: <repository url>
  branch: [branch]
  token: ''
  message: [message]
  name: [git user]
  email: [git email]
  extend_dirs: [extend directory]
  ignore_hidden: false # default is true
  ignore_pattern: regexp  # whatever file that matches the regexp will be ignored when deploying

# or this:
deploy:
  type: git
  message: [message]
  repo: <repository url>[,branch]
  extend_dirs:
    - [extend directory]
    - [another extend directory]
  ignore_hidden:
    public: false
    [extend directory]: true
    [another extend directory]: false
  ignore_pattern:
    [folder]: regexp  # or you could specify the ignore_pattern under a certain directory

# Multiple repositories
deploy:
  repo:
    # Either syntax is supported
    [repo_name]: <repository url>[,branch]
    [repo_name]:
      url: <repository url>
      branch: [branch]

这说明我们用人家的东西,就要找对人家的说明文档!


dfface 的版权声明:所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处,严禁商业用途!