git: fetch vs pull, merge vs rebase

fetch vs pull
fetch will download any changes from the remote branch, updating your repository data, but leaving your local branch unchanged.

pull will perform a fetch and additionally merge the changes into your local branch.

What’s the difference? pull updates you local branch with changes from the pulled branch. A fetch does not advance your local branch.

sync 同步 vs中的名詞,在這裏 同步=先拉取+後推送=先獲取+在合併+最後推送
merge vs rebase

Given the following history:

      C---D---E local
     /
A---B---F---G remote

merge joins two development histories together. It does this by replaying the changes that occurred on your local branch after it diverged on top of the remote branch, and record the result in a new commit. This operation preserves the ancestry of each commit.

The effect of a merge will be:

      C---D---E local
     /         \
A---B---F---G---H remote

rebase will take commits that exist in your local branch and re-apply them on top of the remote branch. This operation re-writes the ancestors of your local commits.

The effect of a rebase will be:

              C'--D'--E' local
             /
A---B---F---G remote

What’s the difference? A merge does not change the ancestry of commits. A rebase rewrites the ancestry of your local commits.

發佈了22 篇原創文章 · 獲贊 1 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章