Git rebase, skip merge-commits

前端 未结 2 678
长发绾君心
长发绾君心 2021-02-04 03:08

Starting with

    hack---F1----M1----F2  (feature)
   /            /
  C1-----C2----C3  (master)

I would like to end up with

           


        
2条回答
  •  执笔经年
    2021-02-04 03:36

    Looking at your original workflow, it seems like you want to ignore merges, the only problem is using -i for an interactive rebase, which preserves merges.

    git checkout -b temp  
    git rebase --onto master hack temp
       * Big drawback is gone!
    git checkout master  
    git merge temp  
    git branch -d temp
    

    Should work exactly how you want. This probably doesn't exactly solve your "general case," though.

提交回复
热议问题