Git 笔记
常用 Git 命令 1. 基础操作 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 # 初始化仓库 git init # 克隆仓库 git clone <repository-url> # 查看状态 git status # 添加文件到暂存区 git add <file> git add . # 添加所有文件 # 提交更改 git commit -m "commit message" # 查看提交历史 git log 2. 分支操作 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 # 查看所有分支 git branch -a # 创建新分支 git branch <branch-name> # 切换分支 git checkout <branch-name> # 创建并切换到新分支 git checkout -b <branch-name> # 合并分支 git merge <branch-name> # 删除分支 git branch -d <branch-name> 3. 远程仓库操作 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # 查看远程仓库 git remote -v # 添加远程仓库 git remote add origin <repository-url> # 推送到远程仓库 git push origin <branch-name> # 拉取远程仓库 git pull origin <branch-name> # 获取远程仓库更新(不自动合并) git fetch origin 4. 撤销操作 1 2 3 4 5 6 7 8 9 # 撤销工作区文件修改 git checkout -- <file> # 撤销暂存区文件修改 git reset HEAD <file> # 撤销最近一次提交 git reset --soft HEAD~1 # 保留工作区和暂存区 git reset --hard HEAD~1 # 完全撤销,不可恢复 5. 标签操作 1 2 3 4 5 6 7 8 9 10 11 12 # 查看标签 git tag # 创建标签 git tag <tag-name> # 创建带注释的标签 git tag -a <tag-name> -m "tag message" # 推送标签到远程仓库 git push origin <tag-name> git push origin --tags # 推送所有标签 6. 配置操作 1 2 3 4 5 6 # 查看当前配置 git config --list # 设置用户信息(当前项目) git config user.name "username" git config user.email "user@email" 全局设置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # 查看全局设置 git config --global -l # 设置全局用户名/邮箱 git config --global user.name "username" git config --global user.email "user@email" # 设置全局代理 git config --global http.proxy http://127.0.0.1:7890 git config --global https.proxy https://127.0.0.1:7890 # 取消全局代理 git config --global --unset http.proxy git config --global --unset https.proxy
Rust 编译加速优化方案
1. 核心优化配置 在项目根目录或全局路径 ~/.cargo/config.toml 中添加以下内容: 1 2 3 4 5 6 7 8 9 [build] # 1. 开启增量编译:复用中间产物,仅重编修改部分 incremental = true # 2. 多线程并行编译:将 crate 拆分为 16 个单元并行处理 rustflags = ["-C", "codegen-units=16"] # 3. 编译器缓存:使用 sccache 避免重复编译未变动的依赖 rustc-wrapper = "sccache" 2. 详细说明与权衡 ① 增量编译 (Incremental) 作用:类似“只重烤焦的那层蛋糕”,不再从头开始。 适用场景:本地开发环境。 注意:在 CI 或生产环境发布构建时建议关闭(设置 CARGO_INCREMENTAL=0),以保证产物的确定性。 ② 代码生成单元 (Codegen Units) 作用:将顺序编译拆分为多线程并行。 效果:在 8 核及以上机器效果极其明显。 代价:由于跨单元优化减少,运行时性能可能微降 (1-2%)。建议: 开发环境:设置为 16。 发布版本:调低至 1 或 4 以保证极致性能。 ③ sccache (Mozilla 缓存工具) 作用:全局缓存编译产物,跨项目复用。 效果:只要依赖项未变,直接从缓存拉取,零等待。 3. 快速设置步骤 第一步:安装 sccache 1 cargo install sccache 第二步:配置环境变量 (可选) 除了修改 config.toml,也可以直接在 Shell 配置文件中加入: ...
Hysteria2 部署笔记
1. 安装与初始化 Hysteria2 提供了一键安装脚本,支持大部分 Linux 发行版 1 2 # 执行官方安装脚本 bash <(curl -fsSL [https://get.hy2.sh/](https://get.hy2.sh/)) 安装完成后,主程序位于 /usr/local/bin/hysteria,配置文件默认位于 /etc/hysteria/config.yaml 2. 服务端配置 (YAML) 以下配置启用了 ACME 自动证书申请、HTTP 后端认证以及 反向代理伪装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 # /etc/hysteria/config.yaml listen: :443 acme: domains: - your.domain.net # 替换为你的解析好的域名 email: your@email.com # 接收证书通知的邮箱 auth: # 使用 HTTP 认证模式,适合对接自己的用户管理系统 http: url: [http://your.backend.com/auth](http://your.backend.com/auth) insecure: false masquerade: type: proxy proxy: url: [https://news.ycombinator.com/](https://news.ycombinator.com/) # 流量探测时伪装的目标 rewriteHost: true 3. 核心黑科技:端口跳跃 (Port Hopping) 由于部分运营商会对单一 UDP 端口进行限速或断流,通过 iptables 实现多端口转发(端口跳跃)可以显著提升稳定性 ...
VLESS + Reality + Vision 部署笔记
1. 准备工作 1.1 选择目标域名 Reality 需要一个目标域名作为伪装。理想的选择是:国外知名、支持 TLSv1.3、且在国内访问延迟较低的网站 辅助工具:DNSlytics (用于查询同 IP 下的优质域名) 1.2 系统网络优化 在部署前,建议开启 BBRv3 或进行 TCP 优化以提升吞吐量 安装 BBRv3: 1 bash <(curl -l -s [https://raw.githubusercontent.com/byJoey/Actions-bbr-v3/refs/heads/main/install.sh](https://raw.githubusercontent.com/byJoey/Actions-bbr-v3/refs/heads/main/install.sh)) 综合 TCP 优化脚本: 1 wget -O tcpx.sh "[https://github.com/ylx2016/Linux-NetSpeed/raw/master/tcpx.sh](https://github.com/ylx2016/Linux-NetSpeed/raw/master/tcpx.sh)" && chmod +x tcpx.sh && ./tcpx.sh 2. 安装与环境配置 2.1 安装 Xray 核心 使用官方脚本一键安装: 1 bash -c "$(curl -L [https://github.com/XTLS/Xray-install/raw/main/install-release.sh](https://github.com/XTLS/Xray-install/raw/main/install-release.sh))" @ install 2.2 生成必要参数 在配置前,需要生成 UUID 以及 Reality 专用的密钥对 生成 UUID: 1 2 xray uuid # 输出示例:2233ebed-68b0-4606-a241-1be5f8ad4668 生成 x25519 密钥对: 1 2 3 xray x25519 # PrivateKey: aIRW_Eh8-n8JEmkHFRxQeHnBipHrxt6OrIbAeUVr12s # PublicKey: YLr6CDT0jCxaxZaDypHnOZzB4D83MWLwR06nSWykzBI 3. 服务端配置 编辑配置文件:/usr/local/etc/xray/config.json ...