In this post I will despcibe how to change git history and make history looking better. First thing we want to do is to make history as much linear as possible, so it is easier to keep track of changes. We can achieve this by rebase.
After this command,
feature-branch will move all commits atop the branch it’s comes from.
-i parameter we have posibility to squash and chnage messages of commiits.
This command takes three last commits and ask us what to do with them by opeining the default editor with file like the one presented below.
pick mean that the commit will be taken, but we can replace this with squash commit, which means two or more commits will be merged. See an exaple below.
Now we can accept the change by continuing the rebase:
After that we can push the changes to the remote. Pretty often we have to force overriding using this command:
In oder to keep history clean sometimes we want to merge our changes on feature branch another branch into main branch as single commit, and we can do this as below: