Talk about git merge--squash

Source: Internet
Author: User

You will often face the merge of the Dev branch or many scattered branches into a public release branch.

But there is a situation where you need to deal with a lot of commit records in your dev branch. These commits do not need to be reflected in the release.

Develop Main Branch

A recent commit to the Develop master branch is "fix ImagePrint bug." We pull out a branch for project development, and there will be a lot of commit records.

git checkout-b develop_newfeature_importdatainterface origin/develop

The commit log of the Develop_newfeature_importdatainterface branch is identical to the develop. We add a point to modify commit.

Now we need to merge the commit of the Develop_newfeature_importdatainterface branch into the develop main branch. In merging into the develop we want to see only one commit in the commit log in develop, and this commit message is not very casual, but conforms to the formal submission process, for example, "Develop: Finished import data Interface ".

We need to re-prepare the commit using the git merge–squash command parameter. (This is a clear merge operation unlike Git rebase, do not confuse the role of these two commands.) )

git merge--squash develop_newfeature_importdatainterface

Updating Cc1fea6. e6fb522
Squash Commit--not updating HEAD
1.txt | 3 + + +
1 file changed, 3 insertions (+)

--squash will suspend commit. Otherwise a merge will automatically commit the commit.

1.txt file is the file we modified, it is now pending commit. Now we just need to resubmit.

Git commit-m ' develop:finished Import Data interface '

So every time the merge will be very refreshing, at a glance, even if the reset is also convenient.

King Qingyue Culture


This article is copyrighted by the author and the blog Park, welcome reprint, but without the consent of the author must retain this statement, and on the article page

Talk about git merge--squash

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: 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.