Git从历史commit中删除个别不需要的commit

如果你有这样的需求,发版时,假设你的main branch上有200个commit,由于某些原因,你需要剔除前100个commit中的3个commit来发版,如果cherry pick的话,需要97次,这里有个简单做法:

git checkout main
git pull
git checkout -b newbranch
git rebase -i HEADE~100
-- in the vim editor, find the 3 commits that need to be deleted
-- change from "pick" to "drop"
-- press ESC
-- insert :wq to exit the vim editor
git rebase --continue
--resolve the conflict first time, you may need to resolve multiple times until there is no conflict

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。