Using Rebase-i will present an interactive page at the terminal. In this interactive page we can make certain changes to the commit to be rebase.
Usage
Git rebase-i <master>
Put the commit of the current branch behind <base>, I will open an editor where you can enter a command for each commit that determines how a single commit is transferred to the new base. You can also change the order of the commit list.
Discuss
Most developers like to use Rebase-i to polish our feature branch while the merge branch is in master. He gave us the chance to merge some commits, delete some commits, and sort commits.
Example
# Start a new featuregit checkout-b new-feature master# edit filesgit commit-a-M "Start Developing a Feature" # Edit mor E filesgit commit-a-M "Fix something from the previous commit" # ADD a commit directly to Mastergit checkout master# Edit Filesgit commit-a-M "Fix Security Hole" # Begin an interactive rebasing sessiongit checkout New-featuregit rebase-i Mas ter
The final command opens an editor with two lines of command.
Pick 32618c4 Start Developing a Featurepick 62eed47 Fix something from the previous commit
In this you can modify the pick command. In this example, we use squash to merge these two commits:
Pick 32618c4 Start Developing a featuresquash 62eed47 Fix something from the previous commit
Save rebase start after closing editor. This is going to open a new editor let's fill in the commit description. The entire process is visualized as follows:
Note that the squash commit has a new ID number, which indicates that he is a completely new commit.
Finally, use the Fase-forward merge to integrate the feature branch:
git checkout mastergit merge New-feature
Git rebase-i