Git rebase-i

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.