33.20 Git Merge

20200908

A pull will do a fetch followed by a merge. A merge will update the local repository to incorporate the current updates from the remote repository.

An alternative to doing a merge is to do a rebase which updates the local repository changes to be based on the sequence of updates from the remote repository. Hence it is rebased!

That is, a fetch:

- o - o - o - H - A - B - C (main)
               \
                P - Q - R (origin/main)

A merge:

- o - o - o - H - A - B - C - X (main)
               \             /
                P - Q - R --- (origin/main)

A rebase:

- o - o - o - H - P - Q - R - A' - B' - C' (main)
                          |
                          (origin/main)

C’ and X should be identical. The history will look different.

A merge is probably better than a rebase in the case where someone else has pulled from your main branch.



Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0