I hope that it will help some developers who were struggling with using git interactive rebase like me before. T10–1234: rebase testing (Main message) - test rebase (detail message) - squash commit - amend commit
I will structure my commit message like this. It will open an editor and allow you to edit your commit message. Then it will open a editor again and allow you to change the latter commits to for sĪfter that, your amend your commit message by this command This is a tricky command because it won’t work if there are other commits in between, so only use it when you see all your commits are in a row. Git rebase -i HEAD~10(10 will be the number of your last commits in a row) If you forgot to do it during your rebase against develop, you can try to rebase against you feature branch with this command (a tricky way) S will squash the message into the message above Then all the commits will squash to the first commit.į will keep the change but get rid of the commit message You can squash all your commits into one during the interactive rebase by changing all pick to either f or s except the first commit, and close the editor. You can squash all your commits into one commit and then give it a meaning commit message, and then create a pull request Ideally, all of your commits should be in a row after origin/develop Extra steps (squash and edit commit message) You can review the commits history after git log - oneline - decorate - graph git push - force-with-lease (overwrite the remote even there is divergent).#important, don’t do any git pull to merge from remote.if there are conflicts, fix it manually, save and commit it.it will open the editor and remove all commits that are NOT yours.
REBASE GIT INSTALL
If you didn’t install code, go to VS Code, CMD + SHIFT + P and search install, and select the option Shell Command: Install 'code' command in PATH
REBASE GIT CODE
editor = code - wait # default editor will be VS Code instructionFormat = %s # add the commit author to the end of each line It will open the editor for you to edit in the VS Code. gitconfig (under the mac home directory, hidden file), setup the following and it will help your interactive rebase. Here is the correct way to do the git interactive rebase Therefore, every time I concatenated my previous commits on top of my latest rebase commits, and the commits were getting more and more. It was because after I finish the rebase, git told me that my local feature branch diverge from remote feature branch and it asked me to merge from remote feature by git pull ( Please do not do this).
REBASE GIT UPDATE
There were a few duplicated commits like the following pick 50560612 A20-3308: first commit pick 0371a340 A20-3308: update failed test pick b0e46622 A20-3308: add test cases pick 19b093b9 first commit pick 1f68040d update failed test I original had 10 commits and there were 38 commits at the end after I did the rebase incorrectly after a few times repeatedly.
I messed things up and the commits in rebase getting more and more. Git rebase is confusing to people who never use it and things will be messed up easily if you don’t do it properly (just like me)
REBASE GIT HOW TO
Git Rebase - how to use interactive rebase properly