Hexo blog multi-endpoint synchronization problem
Take the blog, found only active files on the company computer, if home did not send to continue to update the blog. You can’t copy it around on a USB stick. So I put my blog source files on Github to solve the synchronization problem.
Blog source file synchronization
Execute in the blog root directory
git init
git remote add origin [email protected]:lanpangzhi/lanpangzhi.github.io.git Note that you need to add your own repository lanpangzhi with your own username
git checkout -b hexo Create a new hexo branch and switch to the hexo branch
git add . Commit all changes to the staging area
git commit -m "Solve synchronization problem" # Submit file
git push origin hexo # Push hexo branch
Copy the code
There you have it. The source file is now available on Github.
It is recommended to set Hexo as the default branch.
Git subModule enables third-party topic synchronization
Because we cloned the third-party theme directly into the blog directory before, any changes cannot be pushed to the author’s Git repository. At this time, we need to Fork the third-party theme project to our own repository, and generate a repository with the same name under our own account, and a corresponding URL. We should clone the URL of the repository under our own account.
Perform the following operations.
git submodule add [email protected]:lanpangzhi/hexo-theme-next.git themes/next
Copy the code
Add themes/next from your repository to your Git submodule. Note: Themes /next is a directory that says themes/next because I am using next. If you are not using next, please change next to your third-party theme folder.
The root directory of your blog will have a.gitModules file, which is a configuration file that holds the project URL and local subdirectories that you pull to.
This adds successfully, and then do the following.
git add . Commit all changes to the staging area
git commit -m "Add third-party theme Git submodule" # Submit file
git push origin hexo # Push hexo branch
Copy the code
Replace PC to sync blogs and third party themes
Synchronous blog
Make sure you have Node and Git first on your computer.
npm install hexo-cli -g # Install hexo's scaffolding first
git clone [email protected]:lanpangzhi/lanpangzhi.github.io.git # Download project, since hexo is the default branch, the hexo branch will be downloaded directly here
npm i # install dependencies
hexo s # start server
Copy the code
The rest does its own thing. The blogs have been synchronized.
Note: Every time you deploy your site, remember to do the following.
git add . Commit all changes to the staging area
git commit -m "Add XXX article" # Submit file
git push origin hexo # Push hexo branch
Copy the code
Synchronizing a Third-party Theme
Do the following in the blog root directory.
git submodule init Initialize the local configuration file
git submodule update # pull submodules
Copy the code
If the third-party theme is modified, perform the modification in the third-party theme directory.
git add . Commit all changes to the staging area
git commit -m "Modify theme XXXX" # Submit file
git push origin master Push the master branch
Copy the code
This will push the changed theme to its repository.
This enables multi-endpoint synchronization.
My blog and Github address
blog.langpz.com
github.com/lanpangzhi
reference
Devtian. Me / 2015/03/17 /… Git-scm.com/book/zh/v1/…