33.30 Git Pull
20201117
The default pull behaviour is to perform a merge which can also then create a merge commit, and thus can result in changes being made to the commit history. Whilst this is the original default behaviour of git it is often argued not to be the optional approach.
A pull performs a fetch, to update the local repository with changes to the origin (remote) main repository, and then a merge to reconcile divergent branches.
A rebase is often prefered whan your local changes are not so significant as to require a separate branch off of whatever branch is currently active (e.g. main or dev). A rebase can be used to reconcile a divergent branch, rather than using a merge, to commit over the remote branch and so as to maintain a single branch both locally and remotely. This avoids the sometime confusion of createing minor branches of branches, and works nicely in team development.
There are diverse opinions as to whether to do a merge or a
rebase. A rebase is more like the
update
of earlier version control systems (like Subversion
and CVS). It reduces the number of minor branches being merged and so
leaves merging as an operation on major branches of activity.
To set the default behaviour (globally) to be a rebase use the config command:
The default is:
Some recommend the dafault to simply be an attempt at a fast forward over the upstream commits and to fail if that is not possible.
Further explanations are available from:
- https://salferrarello.com/git-warning-pulling-without-specifying-how-to-reconcile-divergent-branches-is-discouraged/
- https://stackoverflow.com/questions/2472254/when-should-i-use-git-pull-rebase
- https://stackoverflow.com/questions/62653114/how-to-deal-with-this-git-warning-pulling-without-specifying-how-to-reconcile
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