Three min to learn git (vi) multiple commits changed once

Source: Internet
Author: User

Here are some of the two git tricks you'll normally use.

Scene:

You built your own branch, like ZHC.

Git branch-b zhc

And then you did a lot of commits.

What do you want to do with many of these commits as a commit to mainline branch?

Method:

First update mainline to the latest

Git checkout Mainline

Git pull--rebase

Then turn multiple commits of the ZHC branch into a commit

git merge--squash ZHC

Update again to confirm that it is up to date

Git pull--rebase

Git diff Origin mainline

Last push

Git push origin mainline


Scenario Two:

Also, what if you commit on mainline and you find that someone else has made changes to the mainline and push it to the remote repository?

Method:

Many people might first save the commit (Cherry-pick to another branch, or stash up after reset), then pull up the latest and finally commit to the top. There's no need for git to think about this scenario, and that's how it's done. The command is:

Git pull--rebase

It's very convenient to pull all the remote changes down and put your latest commit on top.

Original: http://blog.csdn.net/hongchangfirst/article/details/44671231

Author: Hongchangfirst

Hongchangfirst's homepage: http://blog.csdn.net/hongchangfirst


Three minutes to teach you how to learn git (v) query history

Three minutes to teach you about Git (iv) emergency assistance

Three min to learn git (vi) multiple commits changed once

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.