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

2023-11-13  本文已影响0人  做一只有趣的芦苇

如果你有这样的需求,发版时,假设你的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

上一篇下一篇

猜你喜欢

热点阅读