Fixing the "Git Pull Origin Warning"
git20-05-2021
TL;DR
Execute any of the following:
git config --global pull.rebase false
orgit config pull.rebase false
git config --global pull.rebase true
orgit config pull.rebase true
git config --global pull.ff only
orgit config pull.ff only
For more references: https://git-scm.com/docs/git-pull
Back Story
I was updating my local repository and wanted to make sure my repository is up-to-date with the master
or main
branch. Then got the following warnings:
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint: git config pull.rebase false # merge (the default strategy)
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace “git config” with “git config — global” to set a default
hint: preference for all repositories. You can also pass — rebase, — no-rebase,
hint: or — ff-only on the command line to override the configured default per
hint: invocation.
Google is our friend (privacy not included)
So I started searching for what rebase and fast-forward means. So here it is:
Merge (the default strategy)
git config pull.rebase false
- This keeps the default behavior and suppresses the warning.
Rebase
git config pull.rebase true
- This actually commits on top of the remote branch, maintaining a single branch both locally and remotely (unlike the default behaviour where two different branches are involved — one on local and the other on remote — and, to combine the two, a merge is performed).
fast-forward only
git config pull.ff only
- This only performs the pull if the local branch can be fast-forwarded. If not, it simply aborts with an error message (and does not create any commits).
Support
Thank you for being a valued reader of my blog! Your support means the world to me and helps me continue to create valuable content for you. Here are a few ways you can show your support:
- Share the Love: If you enjoy the articles, consider sharing them with your friends, family and social media followers. Sharing the content helps to reach a wider audience and grow a community that simply shares solving problems.
- Feedback is Appreciated: I value your feedback! Let me know what you think about the content, what topics you’d like to see more of and any suggestions you have for improving my blog. Your input helps me tailor the content to better serve you.
- Buy a Coffee: If you’d like to support financially, consider buying me a coffee. Your donation goes a long way in helping to cover the costs associated with running and maintaining the blog. Even a small contribution can make a big difference!