![]() 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.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 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). 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 the feature branch against develop everyday (to keep your feature branch updated with develop branch).create feature branch from develop when you start on a ticket.However, there will be a chance of conflicts if the pr don’t not merge back to develop soon enough new approach (best practice) (since the feature branch had the latest from develop branch so there weren’t any conflicts most of the time) commit, push to origin in feature branch.branch off from develop branch to a feature branch.git pull from develop after complete a feature.I seldom use interactive rebase in the git but recently I learn a best practice from co-worker and I would like to share my experience in here. Git Rebase - how to use interactive rebase properly
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |