diff --git a/_config.butterfly.yml b/_config.butterfly.yml index 3275519..897d5dd 100644 --- a/_config.butterfly.yml +++ b/_config.butterfly.yml @@ -6,9 +6,14 @@ # ==================== 导航栏 ==================== # 顶部导航菜单项 (图标来自 Font Awesome) nav: - logo: # Logo 图片 URL (留空则显示站点标题) + logo: /images/aaaa.png # Logo 图片 URL (留空则显示站点标题) display_title: true # 是否显示站点标题 +# 站点头像(侧边栏/关于页显示,覆盖主题默认) +avatar: + img: /images/core.jpg # 头像图片路径 + effect: false # 鼠标悬停旋转效果 + menu: 首页: / || fas fa-home 归档: /archives/ || fas fa-archive @@ -16,6 +21,18 @@ menu: 标签: /tags/ || fas fa-tags 关于: /about/ || fas fa-heart +# ==================== 首页副标题 ==================== +# 首页大标题下方的副标题(打字机效果) +subtitle: + enable: true # 是否显示首页副标题 + effect: true # 是否启用打字机动画 + source: 4 # 1:hitokoto 2:yiyan 3:今日诗词 4:固定文本(取自下方 sub) + sub: + - 何年是歸日,雨淚下孤舟。 # 固定文本模式下的副标题内容 + typed_option: # 打字机动画参数 (effect 为 true 时生效) + loop: true + showCursor: false + # ==================== 首页封面 ==================== # 封面大图 / 横幅设置 index: diff --git a/_config.yml b/_config.yml index cc2c75c..18d636f 100644 --- a/_config.yml +++ b/_config.yml @@ -6,7 +6,7 @@ # ==================== 站点基本信息 ==================== # 网站标题 -title: 无名垃圾桶 +title: 个人自留地 # 网站副标题 subtitle: '何年是歸日,雨淚下孤舟。' # 网站描述 @@ -14,7 +14,7 @@ description: 一个记录生活的博客 # 网站关键词,多个关键词可用逗号分隔或写成数组 keywords: 博客,知识库 # 作者名称 -author: lin +author: any # 网站语言 language: zh-CN # 时区,留空时通常使用系统默认时区 @@ -154,10 +154,6 @@ ignore: theme: butterfly theme_config: - nav: - logo: - display_title: true - menu: 首页: / || fas fa-home 归档: /archives/ || fas fa-archive diff --git a/package.json b/package.json index 4bb930e..f1b3830 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,22 @@ "version": "0.0.0", "private": true, "scripts": { - "build": "hexo generate", + "start": "powershell -ExecutionPolicy Bypass -File ./tools/blog.ps1 preview", "clean": "hexo clean", - "preview": "bash scripts/blog.sh preview", - "deploy": "bash scripts/blog.sh deploy", - "server": "hexo server" + "build": "hexo generate", + "server": "hexo server", + "preview": "powershell -ExecutionPolicy Bypass -File ./tools/blog.ps1 preview", + "deploy": "powershell -ExecutionPolicy Bypass -File ./tools/blog.ps1 deploy", + "win:clean": "powershell -ExecutionPolicy Bypass -File ./tools/blog.ps1 clean", + "win:build": "powershell -ExecutionPolicy Bypass -File ./tools/blog.ps1 build", + "win:server": "powershell -ExecutionPolicy Bypass -File ./tools/blog.ps1 server", + "win:preview": "powershell -ExecutionPolicy Bypass -File ./tools/blog.ps1 preview", + "win:deploy": "powershell -ExecutionPolicy Bypass -File ./tools/blog.ps1 deploy", + "linux:clean": "bash ./tools/blog.sh clean", + "linux:build": "bash ./tools/blog.sh build", + "linux:server": "bash ./tools/blog.sh server", + "linux:preview": "bash ./tools/blog.sh preview", + "linux:deploy": "bash ./tools/blog.sh deploy" }, "hexo": { "version": "8.1.2" diff --git a/scripts/blog.sh b/scripts/blog.sh deleted file mode 100755 index d560642..0000000 --- a/scripts/blog.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -cd "$ROOT_DIR" - -PORT="${PORT:-4000}" -HOST="${HOST:-127.0.0.1}" -BRANCH="${BRANCH:-main}" - -usage() { - cat <<'EOF' -用法: - ./scripts/blog.sh preview # 一键预览环境 - ./scripts/blog.sh deploy # 一键构建 + 提交 + 推送到自建 git - -可选环境变量: - PORT=4000 预览端口 - HOST=127.0.0.1 预览监听地址 - BRANCH=main 推送分支 -EOF -} - -preview() { - echo "[preview] clean + start hexo server on ${HOST}:${PORT}" - npx hexo clean - exec npx hexo server -i "${HOST}" -p "${PORT}" -} - -deploy() { - echo "[deploy] clean + generate" - npx hexo clean - npx hexo generate - - echo "[deploy] git add" - git add -A - - if git diff --cached --quiet; then - echo "[deploy] 没有可提交的改动,跳过 commit/push" - exit 0 - fi - - if git diff --cached --quiet --ignore-submodules --exit-code; then - : # keep shellcheck calm - fi - - if ! git rev-parse --verify HEAD >/dev/null 2>&1; then - git commit -m "chore: deploy blog" - else - git commit -m "chore: deploy blog $(date '+%F %T')" - fi - - echo "[deploy] push origin ${BRANCH}" - git push origin "${BRANCH}" -} - -case "${1:-}" in - preview) preview ;; - deploy) deploy ;; - -h|--help|help|"") usage ;; - *) - echo "未知命令: $1" >&2 - usage - exit 1 - ;; -esac diff --git a/source/_posts/Git使用教学.md b/source/_posts/Git使用教学.md index 1c781fe..1bccf71 100644 --- a/source/_posts/Git使用教学.md +++ b/source/_posts/Git使用教学.md @@ -1,10 +1,9 @@ ---- +--- title: Git使用教学 date: 2026-07-08 10:00:00 -tags: [编程, 教学] -categories: 教学 -cover: /img/cover.jpg -top_img: /img/top.jpg +tags: [编程, 教程] +categories: 教程 +cover: /images/Git使用教学/github.png description: 认识一下Git! --- @@ -12,11 +11,11 @@ description: 认识一下Git! Git是当前最先进、最主流的**分布式**版本控制系统,免费、开源!核心能力就是版本控制。再具体一点,就是面向代码文件的版本控制,代码的任何修改历史都会被记录管理起来,意味着可以恢复到到以前的任意时刻状态。支持跨区域多人协作编辑,是团队项目开发的必备基础,所以Git也就成了程序员的必备技能。 -![image](/images/bff72050dee7400db8045109f8ca6119.webp) +![image](/images/Git使用教学/bff72050dee7400db8045109f8ca6119.webp) **🟢主要特点**: -![image.png](/images/05512798305d4a20a38fd3b89be2b6e0.webp) +![image.png](/images/Git使用教学/05512798305d4a20a38fd3b89be2b6e0.webp) Git是Linux之父被迫开发的,为了解决Linux混乱的代码管理而开发的。Linux和Git之父 **李纳斯·托沃兹**(Linus Benedic Torvalds),来自1969年的芬兰。 @@ -50,11 +49,11 @@ Git是Linux之父被迫开发的,为了解决Linux混乱的代码管理而开 ### 工作区/暂存区/仓库 -![image.png](/images/091ebdafedb746d98b5340fa107c8d1b.webp) +![image.png](/images/Git使用教学/091ebdafedb746d98b5340fa107c8d1b.webp) 工作区、暂存区、版本库是Git最基本的概念,关系如下图: -![image](/images/c97776f4f3b64b1e979dde63e634847e.webp) +![image](/images/Git使用教学/c97776f4f3b64b1e979dde63e634847e.webp) **🔸工作区**(Workspace)就是在电脑里能看到的代码库目录,是我们搬砖的地方,新增、修改的文件会提交到暂存区。 @@ -62,7 +61,7 @@ Git是Linux之父被迫开发的,为了解决Linux混乱的代码管理而开 **🔸版本库/仓库**(Repository /rɪˈpɑːzətɔːri/ 仓库)Git的管理仓库,管理版本的数据库,记录文件/目录状态的地方,所有内容的修改记录(版本)都在这里。就是工作区目录下的隐藏文件夹`.git`,包含暂存区、分支、历史记录等信息。 -![image](/images/4b886c1cb4844010a76409ff36beb458.webp) +![image](/images/Git使用教学/4b886c1cb4844010a76409ff36beb458.webp) 如上图,为对应本地仓库目录的结构关系。 @@ -70,13 +69,13 @@ Git是Linux之父被迫开发的,为了解决Linux混乱的代码管理而开 Git的工作流程核心就下面几个步骤,掌握了就可以开始写Bug了。 -![image](/images/666f0c95490744bbafe060f5d44c22b0.webp) +![image](/images/Git使用教学/666f0c95490744bbafe060f5d44c22b0.webp) ### Git状态(图) Git在执行提交的时候,不是直接将工作区的修改保存到仓库,而是将暂存区域的修改保存到仓库。要提交文件,首先需要把文件加入到暂存区域中。因此,Git管理的文件有三(+2)种状态: -![image](/images/f78be8de167c4fcc89b814ffda2e92f7.webp) +![image](/images/Git使用教学/f78be8de167c4fcc89b814ffda2e92f7.webp) --- @@ -97,7 +96,7 @@ git version 2.33.0.windows.2 Git有三个主要的配置文件:三个配置文件的优先级是**① < ② < ③** -![image](/images/31c076f9d4b64b4eadba339a8113559c.webp) +![image](/images/Git使用教学/31c076f9d4b64b4eadba339a8113559c.webp) ```bash #查看git配置 @@ -153,7 +152,7 @@ $ cat 'C:\Users\Kwongad\.gitconfig' 工作目录中的文件并不是全都需要纳入版本管理,如日志、临时文件、私有配置文件等不需要也不能纳入版本管理,那该怎么办呢? -![image.png](/images/042a124fa2fe41b1b64791ffb2c192ec.webp) +![image.png](/images/Git使用教学/042a124fa2fe41b1b64791ffb2c192ec.webp) 在工作区根目录下创建“`.gitignore`”文件,文件中配置不需要进行版本管理的文件、文件夹。“`.gitignore`”文件本身是被纳入版本管理的,可以共享。有如下规则: @@ -180,27 +179,27 @@ doc/*.txt #会忽略 doc/notes.txt 但不包括 doc/server/arch.txt SourceTree的[官网](https://www.sourcetreeapp.com/ "https://www.sourcetreeapp.com/") 下载安装包,支持Window、Mac系统,按照提示完成安装。 -![image.png](/images/938e73a171c745efa3f279d98f60dd79.webp) +![image.png](/images/Git使用教学/938e73a171c745efa3f279d98f60dd79.webp) -![image](/images/1384a781a80042faaf754c0de52b8d6d.webp) +![image](/images/Git使用教学/1384a781a80042faaf754c0de52b8d6d.webp) ### TortoiseGit -![image.png](/images/8165d603319245278464511ad2cc71cb.webp) +![image.png](/images/Git使用教学/8165d603319245278464511ad2cc71cb.webp) [TortoiseGit](https://tortoisegit.org/ "https://tortoisegit.org/") 官网下载安装包,及中文语言包,按照提示完成安装。小乌龟的Git是集成到操作系统里的,直接右键文件夹就可以进行Git操作了。 -![image.png](/images/dca67d3a374d41e0bbae7b5d66c8b0e1.webp) +![image.png](/images/Git使用教学/dca67d3a374d41e0bbae7b5d66c8b0e1.webp) -![image.png](/images/5d4597b570744fbda1cf1879103a0511.webp) +![image.png](/images/Git使用教学/5d4597b570744fbda1cf1879103a0511.webp) -![image.png](/images/7494f0ff8dae4e1c8029fc1640938229.webp) +![image.png](/images/Git使用教学/7494f0ff8dae4e1c8029fc1640938229.webp) ### VSCode中的Git VSCode自带的Git工具基本已经可以满足日常使用了,既有可视化功能,也能敲命令,习惯了不就不用安装其他GUI工具了。不过还是可以再安装一些VSCode插件,来增强Git功能。 -![image.png](/images/2c02bbef03d445b6b3c3e5ce64ae632b.webp) +![image.png](/images/Git使用教学/2c02bbef03d445b6b3c3e5ce64ae632b.webp) --- @@ -229,7 +228,7 @@ Initialized empty Git repository in D:/Project_Files/github.Kwong/KwebNote/.git/ 创建完多出了一个被隐藏的`.git`目录,这就是本地仓库Git的工作场所。 -![image.png](/images/183d6f2e27c34fe8a1dad03d190ad108.webp) +![image.png](/images/Git使用教学/183d6f2e27c34fe8a1dad03d190ad108.webp) 克隆远程仓库,如在github上创建的仓库“`https://github.com/kwonganding/KWebNote.git`” @@ -246,7 +245,7 @@ Resolving deltas: 100% (48/48), done. 会在当前目录下创建“KWebNote”项目目录。 -![image.png](/images/377739fca6a740819ce778c705e9cd22.webp) +![image.png](/images/Git使用教学/377739fca6a740819ce778c705e9cd22.webp) ### 暂存区add @@ -275,11 +274,11 @@ $ git mv [file-original] [file-renamed] 修改文件“R.md”,未暂存: -![image.png](/images/69ca93a857ca45769ae56f0492f1d9c6.webp) +![image.png](/images/Git使用教学/69ca93a857ca45769ae56f0492f1d9c6.webp) 执行`git add .`暂存: -![image.png](/images/7c5ebb71c0bb4bec9a5fa9284c70e8f7.webp) +![image.png](/images/Git使用教学/7c5ebb71c0bb4bec9a5fa9284c70e8f7.webp) ### 提交commit-记录 @@ -287,11 +286,11 @@ $ git mv [file-original] [file-renamed] 多个提交就形成了一条时间线,每次提交完,会移动当前分支`master`、`HEAD`的“指针”位置。 -![image](/images/9a3233f335334f30902d0255ff1a6477.webp) +![image](/images/Git使用教学/9a3233f335334f30902d0255ff1a6477.webp) Sourcetree上的历史记录: -![image.png](/images/77c51e33545943dcb2833872ca9fa798.webp) +![image.png](/images/Git使用教学/77c51e33545943dcb2833872ca9fa798.webp) > 📢一般情况,每完成一个小功能、一个Bu就可以提交一次,这样会形成比较清晰的历史记录。 @@ -311,7 +310,7 @@ Sourcetree上的历史记录: | git **reflog** | 查看所有可用的历史版本记录(实际是HEAD变更记录),包含被回退的记录(**重要**) | | git status | 查看本地仓库状态,比较常用的指令,加参数`-s`简洁模式 | -![image](/images/14f7d7d18ad84b71b547456b5f5d35e1.webp) +![image](/images/Git使用教学/14f7d7d18ad84b71b547456b5f5d35e1.webp) 通过`git log`指令可以查看提交记录日志,可以很方便的查看每次提交修改了哪些文件,改了哪些内容,从而进行恢复等操作。 @@ -347,7 +346,7 @@ $ git log -n2 --oneline Git中最重要的就是提交记录了,其他如**标签**、**分支**、**HEAD** 都对提交记录的“指针”引用,指向这些提交记录,理解这一点很重要。 -![image](/images/13cd7d7c62e0424c8e900754e6494a76.webp) +![image](/images/Git使用教学/13cd7d7c62e0424c8e900754e6494a76.webp) 上图中: @@ -416,7 +415,7 @@ d3e15f9 HEAD@{9}: reset: moving to HEAD~ ☘️画个图更清晰些: -![image](/images/565ccedcf6664d6598178327bdf6f75a.webp) +![image](/images/Git使用教学/565ccedcf6664d6598178327bdf6f75a.webp) ```bash # 查看文件的修改 @@ -435,7 +434,7 @@ $ git diff --shortstat "@{0 day ago}" Git作为分布式的版本管理系统,每个终端都有自己的Git仓库。但团队协作还需一个中间仓库,作为中心,同步各个仓库。于是服务端(远程)仓库就来承担这个职责,服务端不仅有仓库,还配套相关管理功能。 -![image](/images/7566420b76e34e489e59871a4a0da9b3.webp) +![image](/images/Git使用教学/7566420b76e34e489e59871a4a0da9b3.webp) 可以用公共的Git服务器,也可以自己搭建一套Git服务器。 @@ -443,7 +442,7 @@ Git作为分布式的版本管理系统,每个终端都有自己的Git仓库 Git服务器一般提供两种登录验证方式: -![image.png](/images/2c1cc6ce8c34485989cf0b823f00d124.webp) +![image.png](/images/Git使用教学/2c1cc6ce8c34485989cf0b823f00d124.webp) ```bash #查看当前远程仓库使用的那种协议连接: @@ -459,7 +458,7 @@ git config --global http.sslVerify false 基于HTTPS的地址连接远程仓库,Github的共有仓库克隆、拉取(pull)是不需要验证的。 -![image.png](/images/c57d5111fdb54323ba6fd64626f84435.webp) +![image.png](/images/Git使用教学/c57d5111fdb54323ba6fd64626f84435.webp) ```bash $ git clone 'https://github.com/kwonganding/KWebNote.git' @@ -493,19 +492,19 @@ https://kwonganding:[加密内容付费可见]@github.com ### 🔑远程用户登录:SSH -![image.png](/images/73179047882b469cb72949d3a0537be7.webp) +![image.png](/images/Git使用教学/73179047882b469cb72949d3a0537be7.webp) SSH(Secure Shell,安全外壳)是一种网络安全协议,通过加密和认证机制实现安全的访问和文件传输等业务,多用来进行远程登录、数据传输。SSH通过公钥、私钥非对称加密数据,所以SSH需要生成一个公私钥对,公钥放服务器上,私有自己留着进行认证。 -![](/images/b4c7bed1fa8e478aa68aefa3b5e94ff2.webp) +![](/images/Git使用教学/b4c7bed1fa8e478aa68aefa3b5e94ff2.webp) **① 生成公私钥**:通过Git指令`ssh-keygen -t rsa`生成公私钥,一路回车即可完成。生成在“`C:\Users\用户名\.ssh`”目录下,文件`id_rsa.pub`的内容就是公钥。 -![image.png](/images/ea24f85292134500a84374062f7ee6a4.webp) +![image.png](/images/Git使用教学/ea24f85292134500a84374062f7ee6a4.webp) **② 配置公钥**:打开`id_rsa.pub`文件,复制内容。Github上,打开`Setting`➤ `SSH and GPG keys` ➤ `SSH keys` ➤ 按钮`New SSH key`,标题(Title)随意,秘钥内容粘贴进去即可。 -![image.png](/images/0e03cbbc0ee74dad80dd4855e412cba0.webp) +![image.png](/images/Git使用教学/0e03cbbc0ee74dad80dd4855e412cba0.webp) SSH配置完后,可用`ssh -T git@github.com`来检测是否连接成功。 @@ -542,7 +541,7 @@ Hi kwonganding! You've successfully authenticated, but GitHub does not provide s **🔸拉取**(pull):从服务端(远程)仓库更新到本地仓库。 -![image](/images/365395e73a254ef6abfd5a99e78992b0.webp) +![image](/images/Git使用教学/365395e73a254ef6abfd5a99e78992b0.webp) ### fetch与pull有什么不同? @@ -550,7 +549,7 @@ Hi kwonganding! You've successfully authenticated, but GitHub does not provide s > `git pull` = `git fetch` + `git merge` -![image](/images/abf7648ba0314c3f9f5ad30c4e1e20c4.webp) +![image](/images/Git使用教学/abf7648ba0314c3f9f5ad30c4e1e20c4.webp) ```bash # fetch只更新版本库 @@ -577,13 +576,13 @@ Fast-forward 分支是从主线分离出去的“副本”,分支就像是平行宇宙,可独立发展,独立编辑、提交,也可以和其他分支合并。分支是Git的核心必杀利器之一,分支创建、切换、删除都非常快,他非常的轻量。所以,早建分支!多用分支! -![image.png](/images/4b9ab3c40bcf47858c8ee108ab35ff91.webp) +![image.png](/images/Git使用教学/4b9ab3c40bcf47858c8ee108ab35ff91.webp) ### 分支Branch 比如有一个项目团队,准备10月份发布新版本,要新开发一堆黑科技功能,占领市场。你和小伙伴“小美”一起负责开发一个新功能A,开发周期2周,在这两周你们的代码不能影响其他人,不影响主分支。这个时候就可以为这个新功能创建一个分支,你们两在这个分支上干活,2周后代码开发完了、测试通过,就可以合并进要发版的开发分支了。安全、高效,不影响其他人工作,完美! -![image](/images/c58ef8e5f5334ee6909d9c9a55298e71.webp) +![image](/images/Git使用教学/c58ef8e5f5334ee6909d9c9a55298e71.webp) 在实际项目中,一般会建几个主线分支。 @@ -635,7 +634,7 @@ $ git branch 代码仓库可以有多个分支,`master`为默认的主分支,但只有一个分支在工作状态。所以要操作不同分支,需要切换到该分支,`HEAD`就是指向当前正在活动的分支。 -![image](/images/477ba6ccb6224187a72331fbc2cd3b7a.webp) +![image](/images/Git使用教学/477ba6ccb6224187a72331fbc2cd3b7a.webp) ```bash # 切换到dev分支,HEAD指向了dev @@ -656,13 +655,13 @@ ref: refs/heads/dev 把两个分支的修改内容合并到一起,常用的合并指令`git merge [branch]`,将分支`[branch]`合并到当前分支。根据要合并的内容的不同,具体合并过程就会有多种情况。 -![image](/images/0bb900a1fb09455e979ebe78e9ed4717.webp) +![image](/images/Git使用教学/0bb900a1fb09455e979ebe78e9ed4717.webp) ### 🔸快速合并(Fast forward) 如下图,`master`分支么有任何提交,“`git merge dev`”合并分支`dev`到`master`,此时合并速度就非常快,直接移动`master`的“指针”引用到`dev`即可。这就是快速合并(Fast forward),不会产生新的提交。 -![image](/images/d9e4500d07dd4608859822eff0946aa1.webp) +![image](/images/Git使用教学/d9e4500d07dd4608859822eff0946aa1.webp) > **📢强制不用快速合并**:`git merge --no-ff -m "merge with no-ff" dev`,参数`--no-ff`不启用快速合并,会产生一个新的合并提交记录。 @@ -670,7 +669,7 @@ ref: refs/heads/dev 如果`master`有变更,存在分支交叉,则会把两边的变更合并成一个提交。 -![image](/images/11697f2dcf804ad9a9c34836743389f5.webp) +![image](/images/Git使用教学/11697f2dcf804ad9a9c34836743389f5.webp) 上图中,创建`dev`分支后,两个分支都有修改提交,因此两个分支就不在一条顺序线上了,此时合并`dev`到`master`就得把他们的修改进行合并操作了。 @@ -678,13 +677,13 @@ ref: refs/heads/dev 在有冲突的文件中,`<<<<<<< HEAD`开头的内容就表示是有冲突的部分,需要人工处理,可以借助一些第三方的对比工具。人工处理完毕后,完成合并提交,才最终完成此次合并。`=======`分割线上方是当前分支的内容,下方是被合并分支的变更内容。 -![image.png](/images/790e17969958424c992eaf7a204641eb.webp) +![image.png](/images/Git使用教学/790e17969958424c992eaf7a204641eb.webp) ### 变基rebase 把两个分支的修改内容合并到一起的办法有两种:`merge` 和 `rebase`,作用都是一样的,区别是`rebase`的提交历史更简洁,干掉了分叉,merge的提交历史更完整。 -![image](/images/6009e8d4b42f4fdfbaf2e3330b3bd5f9.webp) +![image](/images/Git使用教学/6009e8d4b42f4fdfbaf2e3330b3bd5f9.webp) ```bash $ git rebase master @@ -702,7 +701,7 @@ $ git merge dev 默认标签是打在最新提交的commit上的,如果希望在指定的提交上打标签则带上提交编号(commit id):`git tag v0.9 f52c633` -![image](/images/2bb33deac27f4730b2026ff92ce38a20.webp) +![image](/images/Git使用教学/2bb33deac27f4730b2026ff92ce38a20.webp) | **指令** | **描述** | | --- | --- | @@ -738,7 +737,7 @@ v1 发现写错了要回退怎么办?看看下面几种后悔指令吧! -![image](/images/79de5cfe72814bca8d97411d49e59977.webp) +![image](/images/Git使用教学/79de5cfe72814bca8d97411d49e59977.webp) ### 后悔指令🔥 @@ -775,11 +774,11 @@ Updated 1 path from f951a96 如下图: -![image](/images/45ad235c2b8b440ebe32481e56ab483f.webp) +![image](/images/Git使用教学/45ad235c2b8b440ebe32481e56ab483f.webp) `reset`有三种模式,对应三种参数:`mixed`(默认模式)、`soft`、`hard`。三种参数的主要区别就是对工作区、暂存区的操作不同。 -![image](/images/737dd913911b4e57a2e7dedd4f094d9b.webp) +![image](/images/Git使用教学/737dd913911b4e57a2e7dedd4f094d9b.webp) | **模式名称\\** | **描述** | **HEAD的位置** | **暂存区** | **工作区** | | --- | --- | --- | --- | --- | @@ -818,7 +817,7 @@ ccb9937 (HEAD -> main, origin/main, origin/HEAD) HEAD@{0}: commit: 报表新增 安全的撤销某一个提交记录,基本原理就是生产一个新的提交,用原提交的逆向操作来完成撤销操作。注意,这不同于`reset`,`reset`是回退版本,revert只是用于撤销某一次历史提交,操作是比较安全的。 -![image](/images/3138dde33c5f40a09fe209bb30cd08f2.webp) +![image](/images/Git使用教学/3138dde33c5f40a09fe209bb30cd08f2.webp) 如上图: @@ -849,19 +848,19 @@ $ git revert 41ea42 -m'撤销对***的修改' Git flow(Git工作流程)是指软件项目中的一种Git分支管理模型,经过了大量的实践和优化,被认为是现代敏捷软件开发和DevOps(开发、技术运营和质量保障三者的交集)的最佳实践。Git flow主要流程及关键分支:[原图地址-processon](https://www.processon.com/view/59ec836de4b0c86d400e99f1?fromnew=1 "https://www.processon.com/view/59ec836de4b0c86d400e99f1?fromnew=1") -![image.png](/images/62805963c11f409497cbdf98cfecb5b3.webp) +![image.png](/images/Git使用教学/62805963c11f409497cbdf98cfecb5b3.webp) **✅主分支:master**,稳定版本代码分支,对外可以随时编译发布的分支,不允许直接Push代码,只能请求合并(pull request),且只接受`hotfix`、`release`分支的代码合并。 **✅热修复分支:hotfix**,针对线上紧急问题、bug修复的代码分支,修复完后合并到主分支、开发分支。 -![image.png](/images/e799d590479c4b45a1da4af6d37aa709.webp) +![image.png](/images/Git使用教学/e799d590479c4b45a1da4af6d37aa709.webp) **✅发版分支:release**,版本发布分支,用于迭代版本发布。迭代开发完成后,合并`dev`代码到`release`,在`release`分支上编译发布版本,以及修改bug(定时同步bug修改到`dev`分支)。测试完成后此版本可以作为发版使用,然后把稳定的代码push到`master`分支,并打上版本标签。 **✅开发分支:dev**,开发版本分支,针对迭代任务开发的分支,日常开发原则上都在此分支上面,迭代完成后合并到release分支,开发、发版两不误。 -![image.png](/images/47dee6fb94154ab0abf61abcdf37b3eb.webp) +![image.png](/images/Git使用教学/47dee6fb94154ab0abf61abcdf37b3eb.webp) **✅其他开发分支:dev-xxx**,开发人员可以针对模块自己创建本地分支,开发完成后合并到dev开发分支,然后删除本地分支。 @@ -911,7 +910,7 @@ $ git stash pop 当有一个紧急bug,在`dev`上修复完,我们需要把`dev`上的这个bug修复所做的修改“复制”到`master`分支,但不想把整个dev合并过去。为了方便操作,Git专门提供了一个`cherry-pick`命令,让我们能复制一个特定的提交到当前分支,而不管这个提交在哪个分支。 -![image](/images/fe43365ecea04a0b843ed23e79a77936.webp) +![image](/images/Git使用教学/fe43365ecea04a0b843ed23e79a77936.webp) 如上图,操作过程相当于将该提交导出为补丁文件,然后在当前`HEAD`上重放,形成无论内容还是提交说明都一致的提交。 @@ -921,3 +920,4 @@ $ git cherry-pick [commit] ``` --- +原文链接 :https://juejin.cn/post/7195030726096453690 \ No newline at end of file diff --git a/source/_posts/Markdown使用指南.md b/source/_posts/Markdown使用指南.md new file mode 100644 index 0000000..4ba5981 --- /dev/null +++ b/source/_posts/Markdown使用指南.md @@ -0,0 +1,249 @@ +--- +title: Markdown 使用指南 +date: 2026-07-08 22:00:00 +tags: [Markdown, 写作, 教程] +categories: 教程 +cover: /images/Markdown使用指南/markdown.webp +description: 从零掌握 Markdown 常用语法。每条语法都先给「写法」再给「效果」,照抄即可。 +--- + +## 一、什么是 Markdown + +Markdown 是一种**轻量级标记语言**,用纯文本编写,通过简单符号控制排版。优点: + +- 语法简单,几分钟上手; +- 专注内容,不被格式打扰; +- 通用性强,几乎所有博客、笔记、代码托管平台都支持。 + +下面每一条都先给**写法**(源码),紧接着给出**效果**(实际渲染结果),方便对照学习。 + +## 二、标题 + +用 `#` 的数量表示标题层级,`#` 越多级别越低(建议全文只有一个 `#` 一级标题)。 + +**写法** + +```markdown +# 一级标题 +## 二级标题 +### 三级标题 +#### 四级标题 +``` + +**效果**(演示三级与四级,一、二级即本文各章节样式) + +### 这是三级标题的效果 + +#### 这是四级标题的效果 + +## 三、文本样式 + +### 加粗、斜体、删除线 + +**写法** + +```markdown +**加粗文字** +*斜体文字* +***加粗斜体*** +~~删除线~~ +``` + +**效果** + +**加粗文字** +*斜体文字* +***加粗斜体*** +~~删除线~~ + +### 高亮与上下标 + +> 以下为扩展语法,**标准 Markdown 不渲染**,仅在 Typora、部分平台支持,本站点同样不会渲染,这里如实展示原样。 + +**写法** + +```markdown +==高亮文字== +上标:x^2^ +下标:H~2~O +``` + +**效果(原样,因本站点不支持)** + +==高亮文字== +上标:x^2^ +下标:H~2~O + +## 四、列表 + +### 无序列表 + +**写法** + +```markdown +- 项目一 +- 项目二 + - 子项目(前面加两个空格缩进) +``` + +**效果** + +- 项目一 +- 项目二 + - 子项目(前面加两个空格缩进) + +### 有序列表 + +**写法** + +```markdown +1. 第一步 +2. 第二步 +3. 第三步 +``` + +**效果** + +1. 第一步 +2. 第二步 +3. 第三步 + +### 任务列表 + +> 任务列表为 GitHub 扩展语法,本站点不渲染复选框,这里展示原样写法。 + +**写法** + +```markdown +- [x] 已完成的任务 +- [ ] 待完成的任务 +``` + +**效果(原样)** + +- [x] 已完成的任务 +- [ ] 待完成的任务 + +## 五、链接与图片 + +### 链接 + +**写法** + +```markdown +[显示文字](https://example.com "可选标题") +``` + +**效果** + +[显示文字](https://example.com "可选标题") + +### 图片 + +**写法** + +```markdown +![图片描述](图片地址) +``` + +**效果** + +![示例图片](/img/butterfly-icon.png) + +> 提示:图片语法与链接几乎一样,区别仅在于最前面多一个 `!`。本地图片可写成 `/images/文章名/图片.webp`。 + +## 六、代码 + +### 行内代码 + +**写法** + +```markdown +使用 `npm install` 安装依赖 +``` + +**效果** + +使用 `npm install` 安装依赖 + +### 代码块与语法高亮 + +**写法**(用四个反引号包裹,内部的三反引号才能原样显示) + +````markdown +```python +def hello(): + print("Hello, Markdown!") +``` +```` + +**效果** + +```python +def hello(): + print("Hello, Markdown!") +``` + +## 七、引用 + +**写法** + +```markdown +> 引用内容 +> +> > 嵌套的二级引用 +``` + +**效果** + +> 引用内容 +> +> > 嵌套的二级引用 + +## 八、表格 + +**写法** + +```markdown +| 语法 | 含义 | 示例 | +| ------- | ------ | ------- | +| `**x**` | 加粗 | **x** | +| `*x*` | 斜体 | *x* | +| `` `x` `` | 行内代码 | `x` | +``` + +**效果** + +| 语法 | 含义 | 示例 | +| ------- | ------ | ------- | +| `**x**` | 加粗 | **x** | +| `*x*` | 斜体 | *x* | +| `` `x` `` | 行内代码 | `x` | + +## 九、分隔线 + +连续三个以上的 `-`、`*` 或 `_`(独占一行)即为分隔线。 + +**写法** + +```markdown +--- +``` + +**效果** + +--- + +## 十、实用扩展(平台相关) + +以下语法并非所有平台都支持,按平台能力选用: + +- **脚注**:`正文[^1]` 配合文末 `[^1]: 注释内容`; +- **自动目录**:部分编辑器支持 `[TOC]`; +- **emoji**:`:smile:` 显示 😄(依赖平台); +- **数学公式**:`$E=mc^2$` 行内,`$$...$$` 独立公式块; +- **流程图**:GitHub 等支持 Mermaid 语法。 + +## 总结 + +掌握标题、文本样式、列表、链接图片、代码、引用、表格、分隔线,已能应付 90% 写作场景。核心心法:**先写内容,再管格式**,其余交给 Markdown。把本文收藏,写文章时对照查阅即可。 diff --git a/source/_posts/hello-world.md b/source/_posts/hello-world.md deleted file mode 100644 index 821780c..0000000 --- a/source/_posts/hello-world.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: Hello World ---- -Welcome to [Hexo](https://hexo.io/)! This is your very first post. Check [documentation](https://hexo.io/docs/) for more info. If you get any problems when using Hexo, you can find the answer in [troubleshooting](https://hexo.io/docs/troubleshooting.html) or you can ask me on [GitHub](https://github.com/hexojs/hexo/issues). - -## Quick Start - -### Create a new post - -``` bash -$ hexo new "My New Post" -``` - -More info: [Writing](https://hexo.io/docs/writing.html) - -### Run server - -``` bash -$ hexo server -``` - -More info: [Server](https://hexo.io/docs/server.html) - -### Generate static files - -``` bash -$ hexo generate -``` - -More info: [Generating](https://hexo.io/docs/generating.html) - -### Deploy to remote sites - -``` bash -$ hexo deploy -``` - -More info: [Deployment](https://hexo.io/docs/one-command-deployment.html) diff --git a/source/images/042a124fa2fe41b1b64791ffb2c192ec.webp b/source/images/Git使用教学/042a124fa2fe41b1b64791ffb2c192ec.webp similarity index 100% rename from source/images/042a124fa2fe41b1b64791ffb2c192ec.webp rename to source/images/Git使用教学/042a124fa2fe41b1b64791ffb2c192ec.webp diff --git a/source/images/05512798305d4a20a38fd3b89be2b6e0.webp b/source/images/Git使用教学/05512798305d4a20a38fd3b89be2b6e0.webp similarity index 100% rename from source/images/05512798305d4a20a38fd3b89be2b6e0.webp rename to source/images/Git使用教学/05512798305d4a20a38fd3b89be2b6e0.webp diff --git a/source/images/091ebdafedb746d98b5340fa107c8d1b.webp b/source/images/Git使用教学/091ebdafedb746d98b5340fa107c8d1b.webp similarity index 100% rename from source/images/091ebdafedb746d98b5340fa107c8d1b.webp rename to source/images/Git使用教学/091ebdafedb746d98b5340fa107c8d1b.webp diff --git a/source/images/0bb900a1fb09455e979ebe78e9ed4717.webp b/source/images/Git使用教学/0bb900a1fb09455e979ebe78e9ed4717.webp similarity index 100% rename from source/images/0bb900a1fb09455e979ebe78e9ed4717.webp rename to source/images/Git使用教学/0bb900a1fb09455e979ebe78e9ed4717.webp diff --git a/source/images/0e03cbbc0ee74dad80dd4855e412cba0.webp b/source/images/Git使用教学/0e03cbbc0ee74dad80dd4855e412cba0.webp similarity index 100% rename from source/images/0e03cbbc0ee74dad80dd4855e412cba0.webp rename to source/images/Git使用教学/0e03cbbc0ee74dad80dd4855e412cba0.webp diff --git a/source/images/11697f2dcf804ad9a9c34836743389f5.webp b/source/images/Git使用教学/11697f2dcf804ad9a9c34836743389f5.webp similarity index 100% rename from source/images/11697f2dcf804ad9a9c34836743389f5.webp rename to source/images/Git使用教学/11697f2dcf804ad9a9c34836743389f5.webp diff --git a/source/images/1384a781a80042faaf754c0de52b8d6d.webp b/source/images/Git使用教学/1384a781a80042faaf754c0de52b8d6d.webp similarity index 100% rename from source/images/1384a781a80042faaf754c0de52b8d6d.webp rename to source/images/Git使用教学/1384a781a80042faaf754c0de52b8d6d.webp diff --git a/source/images/13cd7d7c62e0424c8e900754e6494a76.webp b/source/images/Git使用教学/13cd7d7c62e0424c8e900754e6494a76.webp similarity index 100% rename from source/images/13cd7d7c62e0424c8e900754e6494a76.webp rename to source/images/Git使用教学/13cd7d7c62e0424c8e900754e6494a76.webp diff --git a/source/images/14f7d7d18ad84b71b547456b5f5d35e1.webp b/source/images/Git使用教学/14f7d7d18ad84b71b547456b5f5d35e1.webp similarity index 100% rename from source/images/14f7d7d18ad84b71b547456b5f5d35e1.webp rename to source/images/Git使用教学/14f7d7d18ad84b71b547456b5f5d35e1.webp diff --git a/source/images/183d6f2e27c34fe8a1dad03d190ad108.webp b/source/images/Git使用教学/183d6f2e27c34fe8a1dad03d190ad108.webp similarity index 100% rename from source/images/183d6f2e27c34fe8a1dad03d190ad108.webp rename to source/images/Git使用教学/183d6f2e27c34fe8a1dad03d190ad108.webp diff --git a/source/images/2bb33deac27f4730b2026ff92ce38a20.webp b/source/images/Git使用教学/2bb33deac27f4730b2026ff92ce38a20.webp similarity index 100% rename from source/images/2bb33deac27f4730b2026ff92ce38a20.webp rename to source/images/Git使用教学/2bb33deac27f4730b2026ff92ce38a20.webp diff --git a/source/images/2c02bbef03d445b6b3c3e5ce64ae632b.webp b/source/images/Git使用教学/2c02bbef03d445b6b3c3e5ce64ae632b.webp similarity index 100% rename from source/images/2c02bbef03d445b6b3c3e5ce64ae632b.webp rename to source/images/Git使用教学/2c02bbef03d445b6b3c3e5ce64ae632b.webp diff --git a/source/images/2c1cc6ce8c34485989cf0b823f00d124.webp b/source/images/Git使用教学/2c1cc6ce8c34485989cf0b823f00d124.webp similarity index 100% rename from source/images/2c1cc6ce8c34485989cf0b823f00d124.webp rename to source/images/Git使用教学/2c1cc6ce8c34485989cf0b823f00d124.webp diff --git a/source/images/3138dde33c5f40a09fe209bb30cd08f2.webp b/source/images/Git使用教学/3138dde33c5f40a09fe209bb30cd08f2.webp similarity index 100% rename from source/images/3138dde33c5f40a09fe209bb30cd08f2.webp rename to source/images/Git使用教学/3138dde33c5f40a09fe209bb30cd08f2.webp diff --git a/source/images/31c076f9d4b64b4eadba339a8113559c.webp b/source/images/Git使用教学/31c076f9d4b64b4eadba339a8113559c.webp similarity index 100% rename from source/images/31c076f9d4b64b4eadba339a8113559c.webp rename to source/images/Git使用教学/31c076f9d4b64b4eadba339a8113559c.webp diff --git a/source/images/365395e73a254ef6abfd5a99e78992b0.webp b/source/images/Git使用教学/365395e73a254ef6abfd5a99e78992b0.webp similarity index 100% rename from source/images/365395e73a254ef6abfd5a99e78992b0.webp rename to source/images/Git使用教学/365395e73a254ef6abfd5a99e78992b0.webp diff --git a/source/images/377739fca6a740819ce778c705e9cd22.webp b/source/images/Git使用教学/377739fca6a740819ce778c705e9cd22.webp similarity index 100% rename from source/images/377739fca6a740819ce778c705e9cd22.webp rename to source/images/Git使用教学/377739fca6a740819ce778c705e9cd22.webp diff --git a/source/images/45ad235c2b8b440ebe32481e56ab483f.webp b/source/images/Git使用教学/45ad235c2b8b440ebe32481e56ab483f.webp similarity index 100% rename from source/images/45ad235c2b8b440ebe32481e56ab483f.webp rename to source/images/Git使用教学/45ad235c2b8b440ebe32481e56ab483f.webp diff --git a/source/images/477ba6ccb6224187a72331fbc2cd3b7a.webp b/source/images/Git使用教学/477ba6ccb6224187a72331fbc2cd3b7a.webp similarity index 100% rename from source/images/477ba6ccb6224187a72331fbc2cd3b7a.webp rename to source/images/Git使用教学/477ba6ccb6224187a72331fbc2cd3b7a.webp diff --git a/source/images/47dee6fb94154ab0abf61abcdf37b3eb.webp b/source/images/Git使用教学/47dee6fb94154ab0abf61abcdf37b3eb.webp similarity index 100% rename from source/images/47dee6fb94154ab0abf61abcdf37b3eb.webp rename to source/images/Git使用教学/47dee6fb94154ab0abf61abcdf37b3eb.webp diff --git a/source/images/4b886c1cb4844010a76409ff36beb458.webp b/source/images/Git使用教学/4b886c1cb4844010a76409ff36beb458.webp similarity index 100% rename from source/images/4b886c1cb4844010a76409ff36beb458.webp rename to source/images/Git使用教学/4b886c1cb4844010a76409ff36beb458.webp diff --git a/source/images/4b9ab3c40bcf47858c8ee108ab35ff91.webp b/source/images/Git使用教学/4b9ab3c40bcf47858c8ee108ab35ff91.webp similarity index 100% rename from source/images/4b9ab3c40bcf47858c8ee108ab35ff91.webp rename to source/images/Git使用教学/4b9ab3c40bcf47858c8ee108ab35ff91.webp diff --git a/source/images/565ccedcf6664d6598178327bdf6f75a.webp b/source/images/Git使用教学/565ccedcf6664d6598178327bdf6f75a.webp similarity index 100% rename from source/images/565ccedcf6664d6598178327bdf6f75a.webp rename to source/images/Git使用教学/565ccedcf6664d6598178327bdf6f75a.webp diff --git a/source/images/5d4597b570744fbda1cf1879103a0511.webp b/source/images/Git使用教学/5d4597b570744fbda1cf1879103a0511.webp similarity index 100% rename from source/images/5d4597b570744fbda1cf1879103a0511.webp rename to source/images/Git使用教学/5d4597b570744fbda1cf1879103a0511.webp diff --git a/source/images/6009e8d4b42f4fdfbaf2e3330b3bd5f9.webp b/source/images/Git使用教学/6009e8d4b42f4fdfbaf2e3330b3bd5f9.webp similarity index 100% rename from source/images/6009e8d4b42f4fdfbaf2e3330b3bd5f9.webp rename to source/images/Git使用教学/6009e8d4b42f4fdfbaf2e3330b3bd5f9.webp diff --git a/source/images/62805963c11f409497cbdf98cfecb5b3.webp b/source/images/Git使用教学/62805963c11f409497cbdf98cfecb5b3.webp similarity index 100% rename from source/images/62805963c11f409497cbdf98cfecb5b3.webp rename to source/images/Git使用教学/62805963c11f409497cbdf98cfecb5b3.webp diff --git a/source/images/666f0c95490744bbafe060f5d44c22b0.webp b/source/images/Git使用教学/666f0c95490744bbafe060f5d44c22b0.webp similarity index 100% rename from source/images/666f0c95490744bbafe060f5d44c22b0.webp rename to source/images/Git使用教学/666f0c95490744bbafe060f5d44c22b0.webp diff --git a/source/images/69ca93a857ca45769ae56f0492f1d9c6.webp b/source/images/Git使用教学/69ca93a857ca45769ae56f0492f1d9c6.webp similarity index 100% rename from source/images/69ca93a857ca45769ae56f0492f1d9c6.webp rename to source/images/Git使用教学/69ca93a857ca45769ae56f0492f1d9c6.webp diff --git a/source/images/73179047882b469cb72949d3a0537be7.webp b/source/images/Git使用教学/73179047882b469cb72949d3a0537be7.webp similarity index 100% rename from source/images/73179047882b469cb72949d3a0537be7.webp rename to source/images/Git使用教学/73179047882b469cb72949d3a0537be7.webp diff --git a/source/images/737dd913911b4e57a2e7dedd4f094d9b.webp b/source/images/Git使用教学/737dd913911b4e57a2e7dedd4f094d9b.webp similarity index 100% rename from source/images/737dd913911b4e57a2e7dedd4f094d9b.webp rename to source/images/Git使用教学/737dd913911b4e57a2e7dedd4f094d9b.webp diff --git a/source/images/7494f0ff8dae4e1c8029fc1640938229.webp b/source/images/Git使用教学/7494f0ff8dae4e1c8029fc1640938229.webp similarity index 100% rename from source/images/7494f0ff8dae4e1c8029fc1640938229.webp rename to source/images/Git使用教学/7494f0ff8dae4e1c8029fc1640938229.webp diff --git a/source/images/7566420b76e34e489e59871a4a0da9b3.webp b/source/images/Git使用教学/7566420b76e34e489e59871a4a0da9b3.webp similarity index 100% rename from source/images/7566420b76e34e489e59871a4a0da9b3.webp rename to source/images/Git使用教学/7566420b76e34e489e59871a4a0da9b3.webp diff --git a/source/images/77c51e33545943dcb2833872ca9fa798.webp b/source/images/Git使用教学/77c51e33545943dcb2833872ca9fa798.webp similarity index 100% rename from source/images/77c51e33545943dcb2833872ca9fa798.webp rename to source/images/Git使用教学/77c51e33545943dcb2833872ca9fa798.webp diff --git a/source/images/790e17969958424c992eaf7a204641eb.webp b/source/images/Git使用教学/790e17969958424c992eaf7a204641eb.webp similarity index 100% rename from source/images/790e17969958424c992eaf7a204641eb.webp rename to source/images/Git使用教学/790e17969958424c992eaf7a204641eb.webp diff --git a/source/images/79de5cfe72814bca8d97411d49e59977.webp b/source/images/Git使用教学/79de5cfe72814bca8d97411d49e59977.webp similarity index 100% rename from source/images/79de5cfe72814bca8d97411d49e59977.webp rename to source/images/Git使用教学/79de5cfe72814bca8d97411d49e59977.webp diff --git a/source/images/7c5ebb71c0bb4bec9a5fa9284c70e8f7.webp b/source/images/Git使用教学/7c5ebb71c0bb4bec9a5fa9284c70e8f7.webp similarity index 100% rename from source/images/7c5ebb71c0bb4bec9a5fa9284c70e8f7.webp rename to source/images/Git使用教学/7c5ebb71c0bb4bec9a5fa9284c70e8f7.webp diff --git a/source/images/8165d603319245278464511ad2cc71cb.webp b/source/images/Git使用教学/8165d603319245278464511ad2cc71cb.webp similarity index 100% rename from source/images/8165d603319245278464511ad2cc71cb.webp rename to source/images/Git使用教学/8165d603319245278464511ad2cc71cb.webp diff --git a/source/images/938e73a171c745efa3f279d98f60dd79.webp b/source/images/Git使用教学/938e73a171c745efa3f279d98f60dd79.webp similarity index 100% rename from source/images/938e73a171c745efa3f279d98f60dd79.webp rename to source/images/Git使用教学/938e73a171c745efa3f279d98f60dd79.webp diff --git a/source/images/9a3233f335334f30902d0255ff1a6477.webp b/source/images/Git使用教学/9a3233f335334f30902d0255ff1a6477.webp similarity index 100% rename from source/images/9a3233f335334f30902d0255ff1a6477.webp rename to source/images/Git使用教学/9a3233f335334f30902d0255ff1a6477.webp diff --git a/source/images/abf7648ba0314c3f9f5ad30c4e1e20c4.webp b/source/images/Git使用教学/abf7648ba0314c3f9f5ad30c4e1e20c4.webp similarity index 100% rename from source/images/abf7648ba0314c3f9f5ad30c4e1e20c4.webp rename to source/images/Git使用教学/abf7648ba0314c3f9f5ad30c4e1e20c4.webp diff --git a/source/images/b4c7bed1fa8e478aa68aefa3b5e94ff2.webp b/source/images/Git使用教学/b4c7bed1fa8e478aa68aefa3b5e94ff2.webp similarity index 100% rename from source/images/b4c7bed1fa8e478aa68aefa3b5e94ff2.webp rename to source/images/Git使用教学/b4c7bed1fa8e478aa68aefa3b5e94ff2.webp diff --git a/source/images/bff72050dee7400db8045109f8ca6119.webp b/source/images/Git使用教学/bff72050dee7400db8045109f8ca6119.webp similarity index 100% rename from source/images/bff72050dee7400db8045109f8ca6119.webp rename to source/images/Git使用教学/bff72050dee7400db8045109f8ca6119.webp diff --git a/source/images/c57d5111fdb54323ba6fd64626f84435.webp b/source/images/Git使用教学/c57d5111fdb54323ba6fd64626f84435.webp similarity index 100% rename from source/images/c57d5111fdb54323ba6fd64626f84435.webp rename to source/images/Git使用教学/c57d5111fdb54323ba6fd64626f84435.webp diff --git a/source/images/c58ef8e5f5334ee6909d9c9a55298e71.webp b/source/images/Git使用教学/c58ef8e5f5334ee6909d9c9a55298e71.webp similarity index 100% rename from source/images/c58ef8e5f5334ee6909d9c9a55298e71.webp rename to source/images/Git使用教学/c58ef8e5f5334ee6909d9c9a55298e71.webp diff --git a/source/images/c97776f4f3b64b1e979dde63e634847e.webp b/source/images/Git使用教学/c97776f4f3b64b1e979dde63e634847e.webp similarity index 100% rename from source/images/c97776f4f3b64b1e979dde63e634847e.webp rename to source/images/Git使用教学/c97776f4f3b64b1e979dde63e634847e.webp diff --git a/source/images/d9e4500d07dd4608859822eff0946aa1.webp b/source/images/Git使用教学/d9e4500d07dd4608859822eff0946aa1.webp similarity index 100% rename from source/images/d9e4500d07dd4608859822eff0946aa1.webp rename to source/images/Git使用教学/d9e4500d07dd4608859822eff0946aa1.webp diff --git a/source/images/dca67d3a374d41e0bbae7b5d66c8b0e1.webp b/source/images/Git使用教学/dca67d3a374d41e0bbae7b5d66c8b0e1.webp similarity index 100% rename from source/images/dca67d3a374d41e0bbae7b5d66c8b0e1.webp rename to source/images/Git使用教学/dca67d3a374d41e0bbae7b5d66c8b0e1.webp diff --git a/source/images/e799d590479c4b45a1da4af6d37aa709.webp b/source/images/Git使用教学/e799d590479c4b45a1da4af6d37aa709.webp similarity index 100% rename from source/images/e799d590479c4b45a1da4af6d37aa709.webp rename to source/images/Git使用教学/e799d590479c4b45a1da4af6d37aa709.webp diff --git a/source/images/ea24f85292134500a84374062f7ee6a4.webp b/source/images/Git使用教学/ea24f85292134500a84374062f7ee6a4.webp similarity index 100% rename from source/images/ea24f85292134500a84374062f7ee6a4.webp rename to source/images/Git使用教学/ea24f85292134500a84374062f7ee6a4.webp diff --git a/source/images/f78be8de167c4fcc89b814ffda2e92f7.webp b/source/images/Git使用教学/f78be8de167c4fcc89b814ffda2e92f7.webp similarity index 100% rename from source/images/f78be8de167c4fcc89b814ffda2e92f7.webp rename to source/images/Git使用教学/f78be8de167c4fcc89b814ffda2e92f7.webp diff --git a/source/images/fe43365ecea04a0b843ed23e79a77936.webp b/source/images/Git使用教学/fe43365ecea04a0b843ed23e79a77936.webp similarity index 100% rename from source/images/fe43365ecea04a0b843ed23e79a77936.webp rename to source/images/Git使用教学/fe43365ecea04a0b843ed23e79a77936.webp diff --git a/source/images/Git使用教学/github.png b/source/images/Git使用教学/github.png new file mode 100644 index 0000000..f1280ed Binary files /dev/null and b/source/images/Git使用教学/github.png differ diff --git a/source/images/Markdown使用指南/markdown.webp b/source/images/Markdown使用指南/markdown.webp new file mode 100644 index 0000000..1a9e665 Binary files /dev/null and b/source/images/Markdown使用指南/markdown.webp differ diff --git a/source/images/aaaa.png b/source/images/aaaa.png new file mode 100644 index 0000000..891f9f2 Binary files /dev/null and b/source/images/aaaa.png differ diff --git a/source/images/core.jpg b/source/images/core.jpg new file mode 100644 index 0000000..05bba49 Binary files /dev/null and b/source/images/core.jpg differ diff --git a/tools/download-juejin-images.js b/tools/download-juejin-images.js index ca61cb5..bd0701f 100644 --- a/tools/download-juejin-images.js +++ b/tools/download-juejin-images.js @@ -1,4 +1,4 @@ -// 下载 Markdown 中的掘金外链图片到 source/images/,并替换链接为站内路径 +// 下载 Markdown 中的掘金外链图片,按文章归类到 source/images/<文章名>/,并替换链接为站内路径 const fs = require('fs'); const path = require('path'); const https = require('https'); @@ -6,7 +6,9 @@ const http = require('http'); const ROOT = 'c:/Users/Administrator/Desktop/新建文件夹/blog'; const MD = path.join(ROOT, 'source/_posts/Git使用教学.md'); -const OUT = path.join(ROOT, 'source/images'); +// 以文章文件名(去掉扩展名)作为图片子文件夹名,便于按文章管理 +const POST = path.basename(MD, path.extname(MD)); +const OUT = path.join(ROOT, 'source/images', POST); function download(url) { return new Promise((resolve, reject) => { @@ -35,7 +37,7 @@ function download(url) { let content = fs.readFileSync(MD, 'utf8'); const re = /!\[[^\]]*\]\((https:\/\/p3-juejin\.byteimg\.com\/[^)\s]+)\)/g; - const map = {}; // url -> /images/xxx.webp + const map = {}; // url -> /images//xxx.webp let m; const tasks = []; @@ -49,7 +51,7 @@ function download(url) { continue; } const file = hash + '.webp'; - map[url] = '/images/' + file; + map[url] = '/images/' + POST + '/' + file; tasks.push( download(url) .then((buf) => {