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