github pages托管静态网站

基础git配置

git config --global init.defaultBranch master
git config --global user.email '12620716@qq.com'
git config --global user.name 'ByteToy'
git init
git commit -m 'init 2024.6.24'
git remote add github https://github.com/ByteToy/bytetoy.github.io.git

配置github的SSH Key

  1. 生成SSH Key
    ssh-keygen -t rsa -C "12620716@qq.com"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/hotpod/.ssh/id_rsa): 
    /home/hotpod/.ssh/id_rsa already exists.
    Overwrite (y/n)? y
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/hotpod/.ssh/id_rsa
    Your public key has been saved in /home/hotpod/.ssh/id_rsa.pub
    The key fingerprint is:
    SHA256:hkEqj2Z9Yci1RJzSXv46glNclcQcINb/6ZLuPXWYyOI 12620716@qq.com
    The key's randomart image is:
    +---[RSA 3072]----+
    |     +Bo.=oo     |
    |   ..B+oo =      |
    |  . +o=o o       |
    |   = ..+o .      |
    |  + o.o.S. o o o |
    | o   .o.  o = + .|
    |     o   o + . . |
    |    o . o E.o    |
    |     . . +o...   |
    +----[SHA256]-----+
    
  2. 配置github的Key

    Settings-->SSH keys-->New SSH Key
    
  3. 配置项目链接URL 修改.git目录下的config文件,将项目链接改为ssh地址,如git@github.com:ByteToy/bytetoy.github.io.git

    [remote "github"]
         url = git@github.com:ByteToy/bytetoy.github.io.git
         fetch = +refs/heads/*:refs/remotes/github/*
    
  4. 测试

    ssh -T git@github.com
    The authenticity of host 'github.com (20.205.243.166)' can't be established.
    ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
    This key is not known by any other names.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
    Hi ByteToy! You've successfully authenticated, but GitHub does not provide shell access.
    

github提交

此时push即可,无须填写帐号&密码

git push github master

404错误处理

  1. 错误提示

    There isn't a GitHub Pages site here.
    
  2. 处理方式 创建一个README.md,内容随便写,然后提交,刷新即可。

results matching ""

    No results matching ""

    results matching ""

      No results matching ""