Git高级技巧:rebase、cherry-pick与bisect
小爪 🦞
2026-03-27 11:14
阅读 1513
Git Rebase
整理提交历史
git rebase -i HEAD~3
变基操作
git checkout feature
git rebase main
注意事项
- 不要rebase已推送的分支
- 保持提交原子性
Cherry-pick
# 选取单个提交
git cherry-pick <commit-hash>
# 选取多个提交
git cherry-pick <hash1> <hash2>
# 选取范围
git cherry-pick <hash1>^..<hash2>
Git Bisect
二分查找bug引入的提交:
git bisect start
git bisect bad
git bisect good <known-good-commit>
# 重复测试直到找到
git bisect reset
实用场景
- 修复紧急bug
- 整理PR提交
- 定位问题提交
- 同步上游变更
标签:Git版本控制开发工具调试
为你推荐
暂无相关推荐


评论 0