AI 时代 LLM 经常需要读取 git diff,默认行为不要用 delta 修改。
Delta 安装时可能会自动添加配置:
[core]
pager = delta
需要先移除这个配置,然后在 .gitconfig 中添加:
[alias]
ds = -c pager.diff=delta diff
git diff保持原生格式,便于 LLM 读取git ds查看带 delta 的漂亮 diff 效果
11 notes found.
AI 时代 LLM 经常需要读取 git diff,默认行为不要用 delta 修改。
Delta 安装时可能会自动添加配置:
[core]
pager = delta
需要先移除这个配置,然后在 .gitconfig 中添加:
[alias]
ds = -c pager.diff=delta diff
git diff 保持原生格式,便于 LLM 读取git ds 查看带 delta 的漂亮 diff 效果测试覆盖率报告是构建产物,可以在本地或 CI 环境中随时重新生成,不应提交到 Git 仓库。
将 Git 仓库的默认分支从 master 修改为 main。
# 重命名本地分支
git branch -m master main
# 获取远程更新
git fetch origin
# 设置本地 main 分支跟踪远程 main 分支
git branch -u origin/main main
# 设置远程仓库的默认分支
git remote set-head origin -a 通过 homebrew-tap,可以让自己的项目通过 brew install 直接安装。
brew install zhaochunqi/tap/git-open
homebrew-<tap-name>,例如 homebrew-tapFormula/<formula-name>.rb 文件⚠️ 注意: Homebrew 官方不提倡在 Formula 中分发预编译二进制,这被认为是不好的实践。对于 Go CLI 工具等提供预编译二进制的项目,推荐使用 Homebrew Cask 进行分发。参考 Go CLI 工具更适合通过 Homebrew Cask 分发预编译二进制。
class GitOpen < Formula
desc "Open your git repo in browser using one command"
homepage "https://github.com/zhaochunqi/git-open"
version "2.2.1"
on_macos do
on_arm do
url "https://github.com/zhaochunqi/git-open/releases/download/v2.2.1/git-open_Darwin_arm64.tar.gz"
sha256 "9b653ba97f5095e8764f43eeb9ab0e46d01f4bbd14eadd51760b636512812a8c"
end
on_intel do
url "https://github.com/zhaochunqi/git-open/releases/download/v2.2.1/git-open_Darwin_x86_64.tar.gz"
sha256 "ab24e6fe8a49b6f526a785a94a10b56a139430f795346d30f8a5a5db1387223d"
end
end
on_linux do
on_arm64 do
url "https://github.com/zhaochunqi/git-open/releases/download/v2.2.1/git-open_Linux_arm64.tar.gz"
sha256 "8776da29b63a21f0949cda1814e30cc2c926bb6dee4199a9f7f0684486671c70"
end
on_x86_64 do
url "https://github.com/zhaochunqi/git-open/releases/download/v2.2.1/git-open_Linux_x86_64.tar.gz"
sha256 "cf91815149c341d718ea7b26d5d671e261bb8a5701e2de2da803d9a5a6c278c4"
end
end
def install
bin.install "git-open"
end
test do
system "#{bin}/git-open", "--version"
end
end
在所有的 git 全局配置中,配置:
# Configure Git to ensure line endings in files you checkout are correct for macOS
git config --global core.autocrlf input
或者在对应的 ~/.gitconfig 中配置:
[core]
autocrlf = input
但是 github 推荐在 windows 中将这个选项设置为 true,我查了下觉得在三端均采用 input 是非常合理的。
| 配置值 | 含义 |
|---|---|
| true | 双向转换: • 输入(commit)时:CRLF → LF • 输出(checkout)时:LF → CRLF |
| input | 仅输入时转换: • 输入(commit)时:CRLF → LF • 输出(checkout)时:不做转换(保留 LF) |
| false | 完全不转换 |
Software Heritage Archive 是一个代码档案库,可以下载已被删除的 GitHub、GitLab 等平台的代码。
参考:https://til.simonwillison.net/github/software-archive-recovery
git reset --soft HEAD~2 && git commit
研究了一番,发现是 git stash 中有内容。
git clone 或 git fetch 的时候,git 会在本地创建一些”快照”,记录远程仓库的最新状态,但这些不是真正的分支,当远端的 branch 删除之后,本地还会留着。
git fetch --prune
直接配置全局的 gitconfig 即可:
git config --global fetch.prune true Fetch the latest changes from the default remote upstream repository (if set)
git fetch
List all branches (local and remote; the current branch is highlighted by *):
git branch --all
git push origin --delete <branch_name>
git branch -d <branch_name> 在 git config 中创建一个 alias, macOS 下位置在 ~/.gitconfig
[alias]
nah = "!f(){ git reset --hard; git clean -xdf; if [ -d ".git/rebase-apply" ] || [ -d ".git/rebase-merge" ]; then git rebase --abort; fi; }; f"
然后后续的使用可以运行 git nah 即可