Github remote warehouse management + hexo blog migration

github remote warehouse management + hexo blog migration

  • git remote warehouse management
    • Upload to github using git
    • Clone from remote to local
    • Step on pitfalls
  • hexo blog migration

git remote warehouse management

Use git to upload to github

Suggestion: You may encounter some problems during this process. If you read this article thoroughly, you may encounter problems. Good luck!

First have a github account and register on the official website: GitHub

You need to use the software git, download the official website: Git official website

After the installation is complete, open Git Bash ZG4ubmV0L2d6dV96Yg== ,size_16,color_FFFFFF,t_70#pic_center”>
Configure the name and email address on github

git config --global user.name "GitHub username"
git config --global user.email "GitHub email"

You can use git config --global --list to check whether the configuration is successful.

Add SSH key on github

ssh-keygen -t rsa -C "GitHub mailbox name"

After generation, it will be in the user folder of the C drive. Note that it is a hidden file.

For specific adding methods, see the blog: Git Installation and Configuring SSH Key-Windows

After configuration, create locally:

mkdir learngit
cd learngit
pwd
/Users/michael/learngit

Initialize warehouse

git init

Add and create files, such as adding a readme.md

touch readme.md

Add to:

git add readme.md
git commit -m "wrote a readme file"

Add all

git add --all
git commit -m "add all files"

Bind the warehouse address of github

git remote add origin warehouse ssh address

Submit to remote warehouse

git push origin master

NoteThis is submitted to the master branch

If you submit to other branches, such as the main branch, write like this:

git push origin main

If the submitted branch does not exist, it will create one by itself and push to GitHub

Clone from remote to local

git clone ssh address or https address will work

Note: pwd view path is cloned to the current path

Next time you modify the project or add or modify files, you can directly

git add --all
git commit -m "i add a file nihao"
git push origin master

Trading on pitfalls

Pits: These problems may not necessarily be encountered, just take a look
cause:
Since my computer is second-hand, when I use git, I reconfigure my git mailbox and account for the computer. Use the following command:

git config --global user.email "Your github account email address"
git config --global user.name "your github username"

And the key and public key are generated: id_rsa and id_rsa.pub, and the public key is added to my remote warehouse (github). It stands to reason that after such a setting, the git configuration in the computer has been modified to my git account information. But the result was not satisfactory. When I git push, clone, and pull, it still fails, and the failure information is roughly as follows:

remote: Permission to userA/repo.git denied to userB.
fatal: unable to access 'https://github.com/userA/repo.git/': The requested URL returned error: 403

Obviously, according to the prompt, userB does not have permission to push changes to userA’s repo.
There are also some styles as shown below:

Temporary solution

Run under the current git repository: git remote set-url origin https://[email protected]/hello/etl.git Modify the remote url for the current project, which can be a temporary solution. Although this approach can solve the immediate problem, it is not a long-term solution.
Cause of the problem
Since this computer has been configured with ssh using git bash, the system has set the user pointing to github to userB. Every time a push operation is performed, userB’s user information will be read, similar to remembering a password. Because git reads the account that remembers the password for the first time by default, not my own personal git account.
Solution
In this case, you need to delete the configuration of the computer. It is only for Windows computers. For Mac, search it yourself.

Open Control Panel–>User Accounts–>Credential Manager–>Manage Windows Credentials


Find the credentials of github and delete the configuration

Push again, enter your account number and password and submit successfully.

Add a few commands:
View global configuration

git config --global -l

Check whether ssh is successfully bound

ssh -T [email protected]

hexo blog migration

1. Copy the hexo directory that has been configured and generated on your original computer to your new computer. Note that you do not need to copy all of them, just copy the following directories:

_config.yml
 package.json
 scaffolds/
 source/
 themes/


After the copy is completed, name it in the hexo folder

2. First configure the hexo environment on your new computer: install Node.js and install git
3. Install hexo, execute the command:

npm install -g hexo

4. After installation, enter the hexo/directory
5. Module installation, execute the command:

npm install
npm install hexo-deployer-git --save
npm install hexo-generator-feed --save
npm install hexo-generator-sitemap --save

6. Deployment, execute command:

hexo g
hexo d