Fwd: Idea: add --squash to cherry-pick
- From
Noam Yorav-Raphael <noamraph@gmail.com>
- Date
- Aug 11, 2022, 08:53 UTC
- Message-ID
- <CAO8o=D7QC71mnyKSceMpYJzVO4=POva=mJQ1bi0teUHPB9xesA@mail.gmail.com>
- In-Reply-To
- <CAO8o=D6p+aFOeRdTDHwPa1E+V45Uqh-TuSZbz0WU=rE-ksGj_w@mail.gmail.com>
Hi,
Here's something I need regularly, which I haven't found an easy solution for yet. If there's support, I may try and implement it.
The need is described in this Stack Overflow question: https://stackoverflow.com/q/35123108. It's fairly popular (107 votes for the question, 154 for the best answer), but I find the suggested solution lacking.
Basically, I would like to add a flag --squash to the cherry-pick command, that would apply the diff between the start and end of the specified range in one operation.
The use case is that there's a feature branch which I would like to apply on another branch as one commit.
I could use the `-n` flag to apply all the commits from the source branch without committing them. However, if there are conflicts, I would have to deal with them on every commit applied. Instead, what I want is to just apply the diff between the first and last commit, and then deal with the conflicts.
I find this to be a very natural operation. Usual cherry-pick applies the difference between commit A^ and commit A over HEAD. The suggested `git cherry-pick --squash A..B` would apply the difference between commit A and commit B over HEAD.
What do you think?
Thanks, Noam