[Git] git rebase (reduce merge commit)

In foss, we fork git project from upstream our account and clone to local.

We need to make sure that the respository is up-to-date, so sync to upstream is necessary.

But sometimes when we use git pull which is combined as git fetch and git merge, nonecessary merge occurs.

To avoid redundant merge commit, we  use git pull --rebase instead.

redfish[~] $ git pull --rebase upstream master
redfish[~] $ git push origin master <-f>

<-f> : force updated, that’s because you only rebase the local, but origin doesn’t not rebase.

Reference:

https://git-scm.com/book/zh-tw/v1/Git-%E5%9F%BA%E7%A4%8E-%E8%88%87%E9%81%A0%E7%AB%AF%E5%8D%94%E5%90%8C%E5%B7%A5%E4%BD%9C

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s