07_Other-文章记录-sshpass

:点击此处或下方 以展开或折叠目录

前言

记录一些小知识点、工具、文章收藏

01. 链接收藏

地址
MyFreeMP3Typora入门Typora页面美化
Microsoft Store中文文案排版指北Git常见用法总结
ProcessOn牛客网-面经-运开资料JavaScript日期格式化,不足两位数补0
Molunerfinn 大佬面经Akilar:Github Action自动部署AutoPlan.哔哩升级
Jetbrains 激活方法公众号二维码.下载GitHub: BiliBiliToolPro
Snipaste JPG 截图格式倚栏听风.2023计算机保研经历总结Veen Zhao.南师大.考研
批量删除微博博文chatgpt账号-key购买Veen Zhao.南师大.复试
网易云.安卓.dolby_beta.教程下载github

其他:

  1. 03_Other-PC端环境记录

非技术:

地址
酷壳:别让自己“墙”了自己

云服务器:

02. sshpass 非交互登录

ssh 不能在命令行中指定密码

sshpass:

  1. 用于非交互的 ssh 密码验证,允许用 -p 参数指定明文密码

  2. 支持密码从命令行,文件,环境变量中读取

Ubuntu 报错 E: Unable to locate package sshpass

apt-get update ; sudo apt-get install sshpass

参考文章:ssh快捷登录 sshpass+alias

登录脚本(第一次需 SSH 登录)

1
2
3
4
5
6
7
8
$ cat ali.sh
#!/bin/bash

sshpass -p 密码 ssh -o ServerAliveinterval=60 root@IP
# sshpass -p 密码 ssh root@IP

$ chmod +x ali.sh

  • -o option => Can be used to give options in the format used in the configuration file.

  • ServerAliveinterval=60 client每隔60秒发送一次请求给server,然后server响应,从而保持连接(防止连接空闲超时)

定义别名 alias

1
2
3
$ cat ~/.bashrc
# User specific aliases and functions
alias ali='bash /home/peng/sh_file/ali.sh'

参考文章:

  1. Shell 脚本 ssh免密码 登录 远程服务器 sshpass用法示例

  2. Shell脚本免密码登录远程服务器(方法一)

  3. ssh快捷登录 sshpass+alias

  4. Linux – 将自己的shell脚本设置成命令

  5. 配置SSH服务远程连接空闲超时退出时间(包括SSH无法登录、登录缓慢)

03. Xftp 显示隐藏文件

image-20230404224047926

参考文章:Xftp显示隐藏文件的方法

04. Github 多账户 SSH 配置

1
ssh-keygen -f ~/.ssh/id_rsa_gh -C user_gh@gmail.com
  • -b:指定 key 的 bit 数,对于 RSA key 而言,默认是 3072 bits
  • -f:指定 key 的文件名,若需要指定路径,则文件名需要和路径一直,如 ~/.ssh/id_rsa_gh
  • -C:指定新的 comment,即公钥末尾的字符串,一般是邮箱地址,若不指定会是 “username@hostname” 的形式
  • -t:指定私钥类型,一般有 “dsa”, “ecdsa”, “ecdsa-sk”, “ed25519”, “ed25519-sk” 和 “rsa” 等几种,若指定为 rsa 还可以指定签名类型,默认为 “rsa-sha2-512”

Github 不同账户,类似配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$ cat ~/.ssh/config
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/user1_rsa
User user1
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/user2_rsa
User user2
------
Host user_gh.github.com
HostName github.com
User user_gh
IdentityFile ~/.ssh/id_rsa_gh
Host github-qileq.com
HostName github.com
User qileq
IdentityFile ~/.ssh/id_rsa_qileq
Host gitlab.com
HostName gitlab.com
User user_gl
IdentityFile ~/.ssh/id_rsa_gl

  • Host 类型昵称,可以简化登录的输入地址,比如Host ccl,则可以用ssh ccl直接连接

  • HostName 表示连接的远程主机地址

  • IdentityFile 表示指定私钥文件路径

  • Port 指定端口

  • User 指定用户名

修改仓库的 git 信息,将仓库配置 url 的 http://github.com 替换为 ssh config 中设置的 Host 值。

笔者以 java-roam-guide 为例,使用如下两种方式来修改仓库地址:

  1. 执行命令 git remote set-url origin git@github-qileq.com:qileq/java-roam-guid.git

  2. 将该仓库 .git/config 中的 url = git@github.com:qileq/java-roam-guide.git 修改为 url = git@github-qileq.com:qileq/java-roam-guide.git

修改完成后,执行 git remote -v 查看仓库地址是否正确。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 当使用<user1.github.com>替换<github.com>进行访问时,ssh会自动识别为user1
# 配置用户1
Host user1.github.com # 别名,可以随便写一个url。
Hostname github.com # 网站真实的域名,如果是GitHub就不用改了
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_user1 # 指向user1的私钥路径,似乎只能在~/.ssh下,不要随便放
User user1 # 填写user1的Github用户名,不过似乎最后获取的还是真实的Github用户名

# 配置用户2
Host user1.github.com
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_user2 # 指向user2的私钥路径,似乎只能在~/.ssh下,不要随便放
User user2 # 填写user2的GitHub用户名,不过似乎最后获取的还是真实的Github用户名

如果是直接使用 git@github.com,那么ssh将自动识别为config列表的第一个用户,可以认为是单用户模式

由于是多用户,所以在第一次clone一个GitHub地址的时候,需要简单的修改一下对应的域名,此时SSH将可以识别使用哪个用户进行操作,并建立配置记录

1
2
3
4
5
6
# 原始要clone的仓库命令
git clone git@github.com:oneflyingfish/WebServer_C.git

# 对应修改一下<github.com>,user1修改为上面配置的<user1.github.com>即可
git clone git@user1.github.com:oneflyingfish/WebServer_C.git

多用户共用情况下,如果提示设置用户名,一定要设置为局部信息,而不是global。命令应修改为

1
2
3
4
5
6
7
8
# git默认提示的命令
git config --global user.name "your_name"
git config --global user.email "your_eamil"

# 我们应该使用的命令
git config user.name "your_name"
git config user.email "your_eamil"

参考文章:

  1. * SSH 多账号的配置

  2. ssh config多账户/多域名配置

  3. SSH Config 使用

  4. Mac上配置多个SSH

  5. * 配置SSH keys连接GitHub(支持多用户)

  6. 解决 Git 同时部署到 GitHub 和 Gitee 时,密钥 SSH 冲突问题

05. APICloud 打包网页

未成功

APICloud => Web App 创建

图标 https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202304061700919.png

启动页 https://registry.npmmirror.com/mycpen-image-bed/0.0.0-2023/files/image/202304061700867.png

image-20230406161352487

安装后的 APP 因无法开启存储空间权限,未能成功(个人原因,Fomalhaut🥝APP 能设置)

参考教程:将网站 / 博客打包成桌面 APPFomalhaut🥝.留言

06. Hexo 渲染脚注

下文采用 hexo-renderer-markdown-it 渲染器(渲染脚注效果一般,不打算用脚注了)

尽管标准 Markdown 不支持脚注,但很多 Markdown 变种都支持。一般来说,大多数 Markdown 方言和编辑器支持行内脚注和引用式脚注这两种方式,而后者使用更为普遍(原文:在 Markdown 中使用引用式链接和脚注

1
2
npm uninstall --save hexo-renderer-marked
npm install --save hexo-renderer-markdown-it
1
2
3
markdown:
plugins:
- markdown-it-footnote

原文:我的博客的诞生(二)

1
2
3
4
5
6
7
8
Here is a footnote reference,[^1] and another.[^longnote]

[^1]: Here is the footnote.

[^longnote]: Here's one with multiple blocks.

Subsequent paragraphs are indented to show that they
belong to the previous footnote.
1
2
3
Here is an inline note.^[Inlines notes are easier to write, since
you don't have to pick an identifier and move down to type the
note.]

来源:markdown-it/markdown-it-footnote

个人配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# https://butterfly.js.org/posts/ceeb73f/#Math-%E6%95%B8%E5%AD%B8
# https://www.nickxu.top/2022/04/17/Hexo-Butterfly-建站指南(八)使用-KaTeX-数学公式/
# https://github.com/hexojs/hexo-renderer-markdown-it
# https://ezgx.tk/posts/65320/
markdown:
preset: 'default'
render:
html: true
xhtmlOut: false
langPrefix: 'language-'
breaks: true
linkify: true
typographer: true
quotes: '“”‘’'
enable_rules:
disable_rules:
plugins:
- markdown-it-abbr
# installed external plugins also can be enabled
- markdown-it-table-of-contents
- markdown-it-attrs
# - markdown-it-cjk-breaks
- markdown-it-container
- markdown-it-deflist
- markdown-it-emoji
+ - markdown-it-footnote
- markdown-it-ins
- markdown-it-mark
- markdown-it-sub
- markdown-it-sup
- markdown-it-checkbox
- markdown-it-imsize
- markdown-it-expandable
- markdown-it-merge-cells
- '@renbaoshuo/markdown-it-katex'
# - @iktakahiro/markdown-it-katex
# - name: '@neilsustc/markdown-it-katex'
# enable: true
# options:
# strict: false
# - markdown-it-toc-and-anchor
- name: markdown-it-container
options: success
- name: markdown-it-container
options: tips
- name: markdown-it-container
options: warning
- name: markdown-it-container
options: danger
anchors:
level: 1
collisionSuffix: ''
permalink: false
permalinkClass: 'header-anchor'
permalinkSide: 'left'
permalinkSymbol: '¶'
case: 0
separator: '-'
images:
lazyload: false
prepend_root: false
post_asset: false

参考文章:

  1. 在 Markdown 中使用引用式链接和脚注

  2. Markdown 脚注

  3. 百里飞洋 Barry-Flynn(得知脚注)

  4. hexojs/hexo-renderer-markdown-it

  5. * markdown-it/markdown-it-footnote

  6. * 我的博客的诞生(二)

07. Base64 加密邮箱 解密

加密的邮箱地址,使用 base64 加密。在线加密:https://encode.chahuo.com/

解密 javascript:decryptEmail(...),代码示例:https://www.mycpen.cn/

1
<a href="javascript:decryptEmail('bXljcGVuQHFxLmNvbQ==');" title="email"></a>

08. Word 转 MD(Pandoc)

1
pandoc -xxx.docx -o xxx.md

一、下载pandoc
建议使用msi直接安装,而不是下载安装包直接使用,msi的下载方法:安装方法。

二、pandoc转换
1、cmd进入文件夹
打开cmd。
转换到文件所在的路径中。d:进入D盘的路径下,CD D:\Program Files\OneDrive\桌面\temp

2、代码实现

1
pandoc -xxx.docx -o xxx.md # docx 文件转换为 md 文件
image-20230416214320662

参考文章:word文件转md文件

09. GitHub 删除历史记录

1
2
git reset <上一步复制到的字符串>
git push -f

参考文章:GITHUB删除历史记录

10. ChatGPT API Key 个人站

项目地址:

  1. https://github.com/Chanzhaoyu/chatgpt-web

  2. https://github.com/Yidadaa/ChatGPT-Next-Web

参考文章:

  1. 无服务器部署自己的chatGPT

11. 字符画 consolo.log()

推荐http://patorjk.com/software/taag

文字生成字符画:
http://patorjk.com/software/taag
http://www.network-science.de/ascii/

图片生成字符画:
http://www.degraeve.com/img2txt.php
http://life.chacuo.net/convertphoto2char

流程图生成字符画:
http://asciiflow.com/

VSCode 插件:
https://github.com/OBKoro1/koro1FileHeader

参考:https://blog.saop.cc/p/c9df/

12. ERR_HTTP2_PROTOCOL_ERROR 关闭 HSTS

访问网站,偶然性报错:ERR_HTTP2_PROTOCOL_ERROR。试着关闭 HSTS

CDN HTTPS 配置 关闭 HSTS多吉云个人链接

image-20230419193555012

以下内容来自 ChatGPT:

问:ERR_HTTP2_PROTOCOL_ERROR 和 HSTS 有什么联系

image-20230419194615758

问:HSTS 会导致 ERR_HTTP2_PROTOCOL_ERROR 报错吗

image-20230419194650417

13. Clash Parsers

设置 => 配置 => 配置文件预处理

1
2
3
4
5
6
7
8
parsers: # array
- url: https://xxx.xxx/xxx
yaml:
prepend-rules:
- DOMAIN-SUFFIX,xxx.com,香港Az-优化3
- DOMAIN-SUFFIX,xxx.com,GLOBAL
- DOMAIN-SUFFIX,xxx.com,DIRECT

参考链接:

  1. * Clash for Windows:配置文件预处理

  2. * Clash利用parsers进行规则预处理

  3. * Clash使用Parser添加自定义规则并防止更新覆盖

  4. clash for windows自定义规则(不会被更新覆盖)

  5. clash for windows如何设置指定IP或者网站才走xx?

14. Replit 部署 Typecho.TimePlus

步骤:https://github.com/zhheo/TimePlus/wiki/

Demo:https://plog.zhheo.com/

在 Typecho 后台导航栏点击【撰写】,在自定义字段中填写图片地址。并填写文章标题和内容,即对应为图片的标题和简介。

搭建步骤:

  1. Replit Create a Repl,环境选 SQLite;参照 @valetzx/typechonreplit 执行 git clone https://github.com/valetzx/typechonreplit && mv -b typechonreplit/* ./ && mv -b typechonreplit/.[^.]* ./ && rm -rf *~ && rm -rf typechonreplit;注释 main.sh butterfly 相关行,bash main.sh;Run 运行;设置 Typecho 时选择 SQLite 数据库

  2. 按照 TimePlus.Wiki 设置,将 Source code 解压上传 Replit Repl 对应路径,按步骤设置

  3. 图片仓库批量获取图片 URL ls ./bj |awk '{print "https://mycpen.gitee.io/cdn2/image/bj/"$1""}' > C:/Users/Administrator/Desktop/TimePlus.txt

  4. Replit Repl 绑自定义域名,需先 TXT 记录认证(因验证问题无法使用 https)

相关链接:

  1. https://github.com/zhheo/TimePlus/wiki/

  2. https://github.com/zhheo/TimePlus

  3. https://github.com/valetzx/typechonreplit

  4. https://blog.zhheo.com/p/bed74f41.html

  5. Replit

  6. 阿里云.DNS

15. Git 修改提交信息

2023-12-13 更新

使用 git rebase -i HEAD~<n> 修改最近某一次的提交信息,以下来自 chatgpt

当您执行 git rebase -i HEAD~<n> 命令时,会打开一个交互式的编辑器界面,列出最近 <n> 个提交。下面是一个示例,假设您要修改最近的前三次提交的提交信息:

1
2
3
pick 1a2b3c4 Commit message 1
pick 5d6e7f8 Commit message 2
pick 9g0h1i2 Commit message 3

要修改提交信息,将每个提交的行的开头的 pick 改为 rewordr,然后保存并关闭编辑器。修改后的示例如下:

1
2
3
reword 1a2b3c4 Commit message 1
reword 5d6e7f8 Commit message 2
reword 9g0h1i2 Commit message 3

保存并关闭编辑器后,Git 会逐个应用这些提交,并在每个提交之前暂停并等待您编辑提交信息。对于每个提交,Git 会打开一个新的编辑器窗口,允许您修改提交信息。完成修改后,保存并关闭编辑器。

请注意,如果在 rebase 过程中出现冲突,您需要解决冲突并使用 git add 命令将解决后的文件标记为已解决。然后,继续进行 rebase,直到所有提交都被处理完毕。

完成 rebase 后,您可以使用 git log 命令验证提交信息是否已成功修改。

1
$ git log

如果要将修改的提交信息推送到远程仓库,您需要使用 git push --force 命令,因为您已经修改了历史提交。

1
$ git push --force

请确保在进行此操作之前备份您的代码,并与团队成员进行沟通,以免影响其他人的工作。


1
2
3
git commit --amend
git push --force <remote-name> <branch-name>

image-20230513174958143
1
2
3
4
git log --oneline
git commit --amend -m "新的提交信息"
git push --force origin master

image-20230513175153157

16. GitHub: BiliBiliToolPro

地址:https://github.com/RayWangQvQ/BiliBiliToolPro

本地部署

1
2
3
4
5
6
7
8
$ pwd
/root/sh_file/BiliBiliToolPro

$ wget https://github.com/RayWangQvQ/BiliBiliToolPro/releases/download/1.0.3/bilibili-tool-pro-v1.0.3-linux-x64.zip
$ unzip bilibili-tool-pro-v1.0.3-linux-x64.zip
$ cd ./linux-x64/
$ ./Ray.BiliBiliTool.Console --runTasks=Login

1
2
3
4
5
6
7
$ crontab -l
0 1 * * * cd /root/sh_file/BiliBiliToolPro/linux-x64; ./Ray.BiliBiliTool.Console --runTasks=VipBigPoint
0 8 * * * cd /root/sh_file/BiliBiliToolPro/linux-x64; ./Ray.BiliBiliTool.Console --runTasks=Daily
* */12 * * * cd /root/sh_file/BiliBiliToolPro/linux-x64; ./Ray.BiliBiliTool.Console --runTasks=LiveLottery
0 16 * * * cd /root/sh_file/BiliBiliToolPro/linux-x64; ./Ray.BiliBiliTool.Console --runTasks=UnfollowBatched
0 20 * * * cd /root/sh_file/BiliBiliToolPro/linux-x64; ./Ray.BiliBiliTool.Console --runTasks=LiveFansMedal

17. GitHub Compare

原文:https://akilar.top/posts/bbf68ad4/

示例:https://github.com/jerryc127/hexo-theme-butterfly/compare/4.8.5...4.9.0

image-20230916150258235

18. new Date().getFullYear();

JavaScript 获取当前年份

1
2
3
4
5
// 要以自动方式获取明年的年份并将其用于创建日期对象,您可以按如下方式修改代码:
const currentYear = new Date().getFullYear();
const nextYear = currentYear + 1;
const newYearTimestamp = new Date(`${nextYear}-01-01 00:00:00`).getTime() / 1000;

19. JavaScript 解码 Base64

在线加密:https://encode.chahuo.com/

以下来自 ChatGPT

在 JavaScript 中解码 Base64 编码的数据,你可以使用 atob() 函数。该函数可以将 Base64 编码的字符串解码为原始的文本数据。示例代码如下:

1
2
3
const base64String = "SGVsbG8gd29ybGQ=";  // Base64 编码的字符串
const decodedString = atob(base64String); // 解码
console.log(decodedString); // 输出解码后的字符串

在这个例子中,base64String 你要解码Base64编码的字符串。使用atob()函数对它进行解码,然后你就可以处理解码后的原始字符串了。

20. JavaScript 取绝对值

来自 ChatGPT

在 JavaScript 中,你可以使用 Math.abs() 函数来获取一个数的绝对值,从而去除负号。例如:

1
2
let num = -5;
let absNum = Math.abs(num); // absNum将是5

这样,absNum 将会取得 num 的绝对值,而不考虑其正负。

21. JavaScript 三元运算

来自 ChatGPT

你可以使用条件运算符(三元运算符)来判断 e - now1 是否大于 0,然后决定是否执行 +1。下面是优化后的代码:

1
let daysDifference = Math.floor(((e - now1) / 1e3 / 60 / 60 / 24) + (e - now1 > 0 ? 1 : 0));

这行代码首先计算 (e - now1) / 1e3 / 60 / 60 / 24 得到天数差,然后根据 (e - now1 > 0) 条件判断天数差是否大于 0,如果是则加 1,否则加 0。最后使用 Math.floor 向下取整。

22. Snipaste 截图格式改 JPG

参考:https://jingyan.baidu.com/article/25648fc14b3276d091fd00c3.html

右键 → 首选项 → 输出 → 文件名.后缀

实测大大减少图片体积,500 KB (PNG) → 70KB (JPG)

仅适用于保存为本地文件,从剪贴板中粘贴到 typora 里还是 PNG 格式的

本人格式:image-$yyyyMMddHHmmsszzz$.jpg,目的 与 typora 剪贴板 上场时的 alt 命名保持一致

image-20231007031301508

23. CSS 视口单位 dvh, svh, lvh

参考:

  1. https://blog.anheyu.com/posts/e644.html

  2. https://blog.csdn.net/LuckyWinty/article/details/128962918

24. CSS 旋转 rotate(90deg)

来自 ChatGPT

rotate(90deg) 是CSS中的旋转变换指令,用于将元素顺时针旋转90度。这可以应用于任何HTML元素,使其在页面上以指定角度旋转。

逆时针旋转一个元素90度,rotate(-90deg)

1
2
3
.about-page-chicken-soup details[open]>summary:after {
transform: rotate(-90deg);
}

25. Markdown 折叠语法

参考:https://blog.csdn.net/ybb_ymm/article/details/128508243

1
2
3
4
<details> 
<summary>指示标题</summary>
内容
</details>
1
2
3
4
5
6
<details> 
<summary>展开查看</summary>
<pre><code>
此处为代码的块具体内容
</code></pre>
</details>

26. PicGo 图片压缩插件

插件名:picgo-plugin-compress-tinypng

NPM 包:picgo-plugin-tinypng

TinyPNG

起因:picgo-plugin-compress 长久失修,picgo 2.3.1 报错 TypeError: req.end is not a functionissue#64 获知此插件

27. JavaScript copy 事件

来自 ChatGPT

要检测用户是否复制内容,你可以使用JavaScript中的copy事件来捕获复制操作。你可以将事件监听器绑定到copy事件上,然后在该事件触发时执行相应的操作,以获知用户是否复制了内容。

1
2
3
4
document.addEventListener('copy', function(event) {
// 在这里执行你想要的操作,例如记录复制操作或发送数据到服务器
console.log('用户复制了内容');
});
1
2
3
4
5
6
7
8
9
10
11
12
13
document.addEventListener('copy', function(event) {
// 获取复制的内容
var copiedText = window.getSelection().toString().trim();

// 检查复制的内容是否为空
if (copiedText.length > 0) {
// 在这里执行你想要的操作,例如记录复制操作或发送数据到服务器
console.log('用户复制了内容:', copiedText);
} else {
// 复制的内容为空,可以选择不执行任何操作或者执行相应处理
console.log('用户尝试复制空内容');
}
});

28. JavaScript window.onresize

来自:ChatGPT

window.onresize 是 JavaScript 中的一个事件处理属性,它用于指定在浏览器窗口大小改变时要执行的函数。当用户调整浏览器窗口的大小时,就会触发 resize 事件,如果你将一个函数分配给 window.onresize,那么这个函数将在窗口大小改变时被调用。

例如,你可以使用以下方式监听窗口大小改变事件并执行相应的操作:

1
2
3
4
window.onresize = function() {
// 在窗口大小改变时执行的代码
console.log("窗口大小已改变");
};

这对于创建响应式设计或根据窗口大小进行布局调整等任务非常有用。当窗口大小发生变化时,你可以根据需要更新页面内容、样式或执行其他自定义操作。

29. Git 指定远端

参考:http://www.mobiletrain.org/about/BBS/161969.html

1
2
3
4
5
git remote add origin <远程仓库URL>

git push <远程仓库别名> <本地分支名>:<远程分支名>

git push origin master:main

30. Git 删除文件历史提交记录

参考:ChatGPT

1
2
3
4
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch node_modules' --prune-empty --tag-name-filter cat -- --all
git rm --cached node_modules -r

git reflog expire --expire=now --all && git gc --prune=now --aggressive

ChatGPT 还提供了 git filter-branch --tree-filter 'rm -rf node_modules' --prune-empty HEAD 命令删除,运行时间过长,不采用,给出的解释:命令1 使用了 --index-filter--cached,这些参数可以更快地处理 Git 的索引而不需要检查和修改实际的工作树文件

  1. git filter-branch --tree-filter 'rm -rf node_modules' --prune-empty HEAD:

    • 使用 --tree-filter 参数,它会在每个提交上执行指定的 shell 命令。在这种情况下,它会执行 rm -rf node_modules 命令来删除 node_modules 目录。
    • 使用 --prune-empty 选项以删除空提交。
    • 只作用于当前分支 HEAD
  2. git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch node_modules' --prune-empty --tag-name-filter cat -- --all:

    • 使用 --index-filter 参数,它会在 Git 索引上执行指定的命令。在这种情况下,它会执行 git rm -r --cached --ignore-unmatch node_modules 命令,以将 node_modules 从索引中删除。
    • 使用 --prune-empty 选项以删除空提交。
    • 使用 --tag-name-filter cat 选项,以保留提交的标签(tags)。
    • 使用 --all 来指定作用于所有分支。

之前上传 github 时提交了无需提交的 node_modules,如何缩小 .git 的大小

ChatGPT:要缩小.git目录的大小,可以采取以下步骤:

  1. 清理历史提交中的node_modules:首先,你需要清理历史提交中的不必要的node_modules目录。你可以使用git filter-branch命令或git filter-repo工具来重写历史提交以删除node_modules。确保在删除之前备份你的仓库,以防发生问题。

  2. 使用.gitignore:在项目根目录下创建一个名为.gitignore的文件,并将node_modules/添加到其中,以确保不再将该目录包括在提交中。

  3. 执行git rm --cached node_modules -r:这将删除当前暂存区中的node_modules目录,但不会删除物理文件。然后,提交这一变更。

  4. 执行git reflog expire --expire=now --all:这将清理Git的reflog,以确保不再保留对不必要历史提交的引用。

  5. 执行git gc --prune=now:这将触发垃圾收集,清理不必要的数据,从而缩小.git目录的大小。

  6. 推送到远程仓库:如果你使用远程仓库(如GitHub),确保将这些更改推送到远程仓库以同步它们。

请注意,这些步骤会修改你的Git历史,因此在执行它们之前务必小心,确保已备份你的仓库数据。

31. 洛雪音乐导入三方音源

官方源因 TX 警告而报废,详见 issue:https://github.com/lyswhut/lx-music-desktop/issues/1643

详见 issue:https://github.com/lyswhut/lx-music-desktop/issues/1649#issuecomment-1774536022

仓库:https://github.com/OneCodeMonkey/music-sources

32. Clash GUI

起因:Clash for Windows 删库

Clash Verge:https://github.com/zzzgydi/clash-verge/

Clash for Android 存档:https://github.com/Z-Siqi/Clash-for-Windows_Chinese/releases/tag/CFA

Clash for Windows 存档:https://github.com/Z-Siqi/Clash-for-Windows_Chinese

33. GitHub SSH 超时

git pull 报超时、ping github.com 报超时

解决方案

1
2
# git bash 终端
vim ~/.ssh/config

内容如下,第一次 git pull 时输入 yes

1
2
3
4
# GitHub Start
Host github.com
Hostname ssh.github.com
# GitHub End

参考

  1. https://blog.ttiee.tech/posts/2024/71e1/

  2. https://ww-rm.github.io/posts/2024/01/17/githubssh-timeout/

  3. github Using SSH over the HTTPS port

  4. github About GitHub’s IP addresses

34. Hexo 隐藏文章

参考:JIeJaitt | Hexo隐藏文章

  1. Front-Matter 配置 published 参数

    1
    2
    3
    4
    ---
    title: Foo
    published: false
    ---
  2. 存为草稿

    1
    2
    # 路径 source/_drafts/
    hexo new draft <title>
  3. 插件,hexo-hide-posts 等

官方参考

  1. https://hexo.io/docs/front-matter#Settings-Their-Default-Values

  2. https://hexo.io/zh-cn/docs/writing.html