In the company I work for, we use Gerrit (unfortunately) and I need to flatten non-pushed commits into one comit. When I check the commit list in InteliJ, I see:
ed4ad5ffd67504a37a43ae6bf66d0f31456e4e81 (HEAD -> develop) [CSTC-1096] ESlint implementation with fixed files
f70a86aabb5bb5f6c8890688aad543c94d8891bb Merge branch 'migrating-from-tslint-to-eslint' into develop
3a6217f7cf98463176c3959d109868497f2c8928 (origin/migrating-from-tslint-to-eslint, migrating-from-tslint-to-eslint) ign
ore webpack.config.js file
04689eafd432f90ede9a5ce9e1474af0474ea176 (origin/develop) [CSTC-1087]: Poprawka do konfiguracji
c6393dd6201099535bef94e36066819dd1dd1467 add package-lock
205c5e97cf0c031df4d63e579a0e2a5f41470014 readme update
339a23faf5bad941d86a4d3160ae8eaebaf57b07 add husky and lint-staged
047aff160006c70b257f931fd2133cdaa54cc1e1 [CSTC-1090]: Dodanie logiki wyświetlania komponentów
5c46bdab5490f07a15067a9b2dfa14c804f7eb1e eslint reinstallation
ddbeac7ed37fffca6a7587f7cbee43faececb394 removal of eslint and update of readme
302d3c1b4c728078decf826347eed9ef49161a74 [CSTC-532] translation fixes and update styles for datepicker
However, when I type git rebase --interactive 302d3c1b4c728078decf826347eed9ef49161a74
I can see:
pick 047aff1 [CSTC-1090]: Dodanie logiki wyświetlania komponentów
pick 04689ea [CSTC-1087]: Poprawka do konfiguracji
pick ddbeac7 removal of eslint and update of readme
pick 5c46bda eslint reinstallation
pick 339a23f add husky and lint-staged
pick 205c5e9 readme update
pick c6393dd add package-lock
pick 3a6217f ignore webpack.config.js file
pick ed4ad5f [CSTC-1096] ESlint implementation with fixed files
so if I do squash on all commits (except the first one) my final commit will be [CSTC-1090]: Dodanie logiki wyświetlania komponentów
.
And I want the final commit to be the last commit created ([CSTC-1096] ESlint implementation with fixed files
)
The resulting commit will neither be the first or the last, it will be the combination of all commits between.
And by default the message used is the combination of all messages but most tools just display the 1st line which would be the message of the 1st commit.
Thus what you want is "just" to choose the right message to use for the resulting commit. When using stash
, Git should already asks you for the message to use: just make sure to use the one you actually want.