Github Hexo one-click update

After this blog was replaced with the Hexo backend, it became bound to 3 warehouses: display warehouse, backend warehouse, and theme warehouse. As a result, three pairs of account passwords need to be entered for each update, which is very inconvenient. After integrating the data collected from various sources, a one-click update program can be summarized, which can synchronize the background code, theme code and display code at one time.

  1. It turns out that the Next theme code can no longer be used directly. Even if the back-end code is taken out to build a warehouse, the theme code cannot be modified by myself. Take themes\nextout the theme code in the directory separately, and build a github warehouse for the original theme code directory! Then copy the theme code back out! submit!

  2. Follow the existing operating steps on the Internet to set the global password-free update of the account. Now it is said that github also has a secret-free key for a single warehouse, but I do not recommend using a single warehouse key in the Hexo blog environment. After all, updating several warehouses at a time is not convenient for management.

    Here is a little repeat.

    In Git Bash cd ~; ssh-keygen -t rsa -C "你的邮箱地址", then press Enter to set all the default settings.

    Continue to execute cd ~; cd .ssh; cat id_rsa.puband copy from the ssh-rsabeginning to the end of the paragraph.

    Open Github on the web page, SSH and GPG Keys, New SSH Key in Account Settings, enter the name at will, and paste the pub content just copied in the text field below.

  3. After setting up here, try git push origin and find that you still have to enter a password. After we have reviewed the information found in the wrong way, beginning git clone when using a https://github.com/用户名/仓库名way. This is called the HTTPS method, but the SSH method is used above, not the HTTPS method. Therefore, the format of the remote warehouse address needs to be modified to the SSH format.

    Enter the warehouse .gitdirectory and edit the configfiles inside . The inside of urlthe https://github.com/用户名/仓库名change [email protected]:用户名/仓库名.

    All three warehouses must be changed like this! But the address of the display warehouse is not in the configfile, but the file in the root directory of the back-end warehouse _config.yml. Most below there deploy, the inside repochanged [email protected]:用户名/仓库名.

  4. After the secret-free update is configured, write a one-click update CMD batch and put it in the project root directory.

git add .
git pull origin master
git commit -m "update"
git push origin -u master
cd themes/next
git add .
git pull origin master
git commit -m "update"
git push origin -u master
cd ..
hexo clean && hexo g && hexo d
  1. After the batch processing is done, you can edit the theme code and background code and execute it directly in the root directory of the background warehouse ./保存的CMD文件名.cmdto realize a command to update the display warehouse, background warehouse, and theme warehouse together.

Guess you like

Origin blog.csdn.net/qq_35977139/article/details/107423728