Introduction: Under normal circumstances, the relevant configuration information of our blog is local, not uploaded to the server, so when we want to reinstall the system on other devices, such as the company’s computer or the original computer, then we can not maintain our blog, see my blog for details

I. Environment configuration

Install Node.js install Git install Hexo

Create a branch

The static blog files generated by Hexo are uploaded to GitHub and are placed on the Master branch by default, while some related configuration files are local

The hexo source files (deployment environment files) can be placed on the Hexo branch (you can create a new Hexo branch) and git clone the Hexo branch on a new computer

1. Create a hexo branch for the warehouse

Create a hexo branch in the Github username. Github. IO repository.

2. Set the default branch

Switch to the hexo branch and set the Default branch to hexo in the warehouse ->Settings->Branches->Default Branch. Then click Update to save.

3. Upload configuration files to Github

This step needs to be performed on the computer where the blog profile and topic profile reside. To learn about git commands, go here

1. Clone hexo branch

1.1 in place will be the new hexo branch of cloned to the local, git clone [email protected]: Sandop/Sandop lot. IO. Git, cloning address to your address; IO file, run the following command: CD username. Github. IO; 1.3 Run the Git branch command under Git Bash in the current directory to view the current branch. The new branch is hexo

2. Upload the deployment file

2.1 Copy all the deployment files of the local blog (all files in the Hexo blog project directory) into username. Github. IO

2.2 Prepare to submit all documents to the Hexo branch with the following considerations in mind:

Remove the.git directory for the theme within the Themes directory (if there is one) as one Git repository cannot contain another or submitting the theme folder will fail

If you delete the themes directory, git will not be able to use git pull to update the theme. If you need to update the theme, clone the latest version of the theme in another location and copy the content to the current theme directory

2.3 Commit all files to the hexo branch using a terminal or management tool, and run git add., git commit -m “First commit hexo branch” (the quotes can be changed), git push;

2.4 The Master branch and the Hexo branch each hold a version. The master branch is used to save the static resources of the blog and provide the blog page for people to visit. The Hexo branch is used to back up the blog deployment files for its own maintenance and updates, and there is no conflict between the two in a GitHub repository

4. Sync to other computers

  1. Add the SSH key generated for your new computer to your GitHub account;

  2. Clone the hexo branch of username. Github. IO to the local git repository on the new computer.

  3. Go to username.github. IO and execute NPM install(since the repository has a. Gitignore file that ignores the node_modules folder by default, the hexo branch of the repository does not store this directory, so install is required).

  4. Install the hexo command on the new computer, NPM install -g hexo;

  5. Here you can start blogging on your new computer!

    5.1 Edit, write articles or make other blog updates

    5.2 Run git add., git commit -m ‘***’, and git push in sequence to ensure that the XXX branch version is up to date

    5.3 Execute hexo clean && Hexo G && Hexo D, and you will find that the latest change has been updated to the master branch.

  6. Every time you change your computer to update your blog, it’s best to do so before you change itgit pullPull up the latest update