Intellij - How to squash local branch only

前端 未结 2 471
情书的邮戳
情书的邮戳 2021-02-05 08:56

When using Git inside of Intellij, how do I squash all of my commits for a local branch? What settings do I use in the rebase branch window?

I\'ve tried setting the Onto

相关标签:
2条回答
  • 2021-02-05 09:18

    It might be a little uncomfortable but you can use the git notation of HEAD~ so in the "Onto" field you'd write the amount of commits you want to include like:

    In this example I have 4 (the last 4) commits I want to combine into 1.



    In the opening dialog the entries are listed in order, so you need to squash all after the first one with the drop box. (I made the first a reword but that's not needed as there will be a message-change dialog for the squashing anyway, so it can be left on 'pick')



    then just a new message for the combined commits and you're done.

    0 讨论(0)
  • 2021-02-05 09:33

    If you want something like "git merge -squash" means merge a branch to another branch (possibly "master") with one commit contains all of the changes, you can use "Merge Changes..." option in Intellij. Just double press shift and type "Merge Changes". In the opened dialog select what branch you want to merge and then select "Squash commit" option.

    0 讨论(0)
提交回复
热议问题