git commit --amend → 修改上次提交 | git config user.name <name> → 设置仓库作者名 |
git revert <commit> → 撤销提交 | git config --global user.name <name> → 全局作者名 |
git reset <file> → 从暂存区移除文件 | git config --global user.email <email> → 全局邮箱 |
git reset --soft <commit> → 回退提交,保留暂存和工作区 | git config --global alias.<alias> <cmd> → 创建别名 |
git reset --mixed <commit> → 回退提交,保留工作区(默认) | git config --system core.editor <editor> → 设置编辑器 |
git reset --hard <commit> → 回退提交,丢弃修改 | git config --global --edit → 编辑全局配置 |
git clean -n → 预览删除未跟踪文件 | git push <remote> --force → 强制推送(危险) |
git reflog → 查看 HEAD 历史 | git push <remote> --all → 推送所有分支 |
git log -<n> → 限制提交数量 | git rebase <base> → 将分支变基 |
git log --stat → 文件修改统计 | git rebase -i <base> → 交互式变基 |
git log -p → 提交详细 diff | git rebase --continue → 继续变基(解决冲突后) |
git log <since>..<until> → 指定范围历史 | git rebase --abort → 中止变基 |
git log -- <file> → 某文件历史 | git log --author="<pattern>" → 按作者搜索 |
git diff HEAD → 工作区 vs 最近提交 | git log --grep="<pattern>" → 按说明搜索 |
git diff --cached → 暂存区 vs 最近提交 | git log --graph --decorate → 图形化历史 |