ORIGIN

Unable to deploy hexo blog using another git account

HexoError 2 mins368 words
This article was written 308 days ago. The content of the article may be out of date.

I’ve ran into a problem recently while deploying my HEXO blog to GitHub.

Problem Description

First, I have two GitHub account, and I want to push one blog folder to one account and another folder to another account.

But somehow, I can’t deploy it because it use my number 1 account for number two folder.

I’ve already add ssh-key to the second GitHub account.

Tried methods

  • change the local git account

    1
    2
    git config --local user.name "hexo-theme-last"
    git config --local user.email "xxx@xxx.com"
  • change the global git account

    1
    2
    git config --global user.name "hexo-theme-last"
    git config --global user.email "xxx@xxx.com"
  • Set the email and user in _config.yml file in blog root directory.

    1
    2
    3
    4
    5
    6
    deploy:
    type: git
    repo: git@github.com:hexo-theme-last/hexo-theme-last.github.io.git
    branch: master
    name: hexo-theme-last
    email: 2061026079@qq.com
  • deploy with pamaraters

    1
    hexo d -u hexo-theme-last -e xxx@xx.com

The weird things is that no matter how I change, it will still use my first account to deploy.

And then I test the ssh connection, create a config file in .ssh directory

1
2
3
4
5
6
7
8
9
Host github2
HostName github.com
User git
IdentityFile /home/o_oyao/.ssh/id_rsa_last

Host o_oyao
HostName github.com
User git
IdentityFile /home/o_oyao/.ssh/id_rsa

And then I run this command, it works well.

1
2
$ ssh -T github2
Hi hexo-theme-last! You've successfully authenticated, but GitHub does not provide shell access.

But if I run this, it will use the first account ssh as default.

1
2
$ ssh -T git@github.com
Hi DyingDown! You've successfully authenticated, but GitHub does not provide shell access.

Solution

Because I want to test whether is only hexo using old account or git using old account, I pushed the original code to the second GitHub account(hexo-theme-last).

Then I realize it need a personal access token

Finally, I solve this problem by using personal access token in hexo _config.yml file.

1
2
3
4
5
6
deploy:
type: git
repo: https://my-personal-access-token/github.com/hexo-theme-last/hexo-theme-last.github.io.git
branch: master
name: hexo-theme-last
email: xxx@xx.com
TOP
COMMENT
  • ABOUT
  • |
o_oyao
  The Jigsaw puzzle is incomplete with even one missing piece. And I want to be the last piece to make the puzzle complete.
Like my post?
Default QR Code
made with ❤️ by o_oyao
©o_oyao 2019-2024

|