历史挖掘与整理 Pro Git · 7.1 / 7.5-7.6

命令说明
git log --follow <文件>跟踪文件在重命名之前的历史
git log main..feature只看 feature 有而 main 没有的提交(A...B 三点看双方独有)
git log --since="2 weeks ago" --author="Bill"按时间 / 作者过滤历史
git log --no-merges --oneline排除合并提交(--merges 反之只看合并)
git log --stat -1查看某次提交的文件改动统计
git show <提交>:<文件>直接查看历史版本里的某个文件内容
git diff --word-diff单词级差异,看文档 / 文案改动更直观
git difftool -t vscode用图形化工具看差异(先配置 diff.tool
git commit --fixup=<提交>把提交标记为某提交的"修正",等待自动归位
git rebase -i --autosquash <基准>自动把 fixup 提交合并进目标提交,历史干净无痕
git filter-branch --tree-filter '命令' -- --all逐提交重写全部历史(官方已不推荐,大仓库改用 git-filter-repo)
工作流:开发中改漏 → git commit --fixup=HEAD^;推送前 → git rebase -i --autosquash main,修正自动归位,不用手调 rebase 清单。