美文网首页
Git从历史commit中删除个别不需要的commit

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

作者: 做一只有趣的芦苇 | 来源:发表于2023-11-13 10:53 被阅读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

    相关文章

      网友评论

          本文标题:Git从历史commit中删除个别不需要的commit

          本文链接:https://www.haomeiwen.com/subject/suxdwdtx.html