Since git 2.29, released in october 2020, you can leverage negative refspec to exclude a specific branch to be fetched.
For GitHub Pages, you can do it like so:
git config --add remote.origin.fetch '^refs/heads/gh-pages'
And Dependabot:
git config --add remote.origin.fetch '^refs/heads/dependabot/*'
You can read more about it on https://github.blog/2020-10-19-git-2-29-released/#user-content-negative-refspecs