Yep, the remote.<name>.fetch config option is a "refspec" (essentially a
glob of src and dst) that will tell git what remote branches to fetch
when you run git fetch. Because the option is usually remote/repository
specific, it's probaby best to modify it in .git/config in the repo
instead of ~/.gitconfig.
The default that is probably already in your .git/config file looks
something like this:
[remote "asf"]
fetch = +refs/heads/*:refs/remotes/asf/*
In this case, the src of the fetch is all the remote branches
(refs/heads/*) and the dst of the branches is refs/remots/asf/*. So all
remote branches are fetched and a locally tracking branch is created
named "asf/*".
You can also specify multiple fetch options to fetch multiple patterns.
Additionally, they can also be prefixed with a carat (^) to negate the
pattern. If a remote branch matches any negated refspec then it will not
be downloaded. So to ignore dependabot branches, we can add a new
negation fetch option to the config like this:
[remote "asf"]
fetch = +refs/heads/*:refs/remotes/asf/*
fetch = ^refs/heads/dependabot/*
Note that there is no dst in a negated refspec.
Now when you git fetch, git will not download any dependabot branches.
It doesn't look like git fetch --prune will delete your existing locally
tracking dependabot branches, so you will need to manually delete them
using git branch -r -d, for example:
git branch -d -r
asf/dependabot/docker/containers/release-candidate/fedora-minimal-36
The git-fetch man page has a section on "<refspec>" if you want to do
anything more complex with your fetch options.
On 6/16/22 3:13 PM, Mike Beckerle wrote:
Is there a basic technique I can put in my ~/.gitconfig so that my daffodil repo
clone won't show dependabot and scala steward branches?
Basically, I don't want to fetch info about commits that have "dependabot" in
their remote branch name. For any remote.
E.g., see screenshot here from qgit:
image.png
or this one:
image.png