Everybody has seen a history full of “Merge branch ‘main’ of …” commits that nobody meant to make. They come from git pull quietly merging when your branch and the remote have both moved. One setting makes git ask you first.
git config --global pull.ff only
With this, git pull only goes ahead when the update is a fast-forward, which means your branch has nothing the remote lacks. The manual says it is the same as giving --ff-only on the command line, and that it overrides merge.ff when pulling.
When the branches have diverged, git stops with an error instead of creating a merge commit. That is the moment you decide what you want:
git pull --rebase
puts your commits on top of the new ones, while git pull --no-ff makes the merge on purpose.
Caveat: the error looks scary the first time and scripts that run git pull will fail on a diverged branch. That is the point, but check any automation that updates a checkout before you switch the global setting. The option only affects git pull, not a normal git merge.
Leave out --global to set it for just one repository.
Further reading: git config, pull.ff (Git documentation)
Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more