1

It is possible to set up rules like fetch = +refs/heads/*:refs/remotes/origin/* to fetch all branches matching certain glob.

But is it possible to exclude something from the list? For example, I don't want to fetch anything from refs/heads/X/* because it is used by our automated tool, and there're often lots of small branches I have no need to see ever.

Ivan Danilov
  • 14,287
  • 6
  • 48
  • 66

2 Answers2

2

Unfortunately, no. To exclude X/* you must list (positively) everything not X/*.

Depending on how you name your refs / branches, this may be easy enough, or may be especially difficult. You could automate it to a large extent using git ls-remote and a script (use grep, or python code, or whatever, to exclude X/* while adding every other reference).

torek
  • 448,244
  • 59
  • 642
  • 775
2

Starting with Git v2.29.0, there is a way. Negative refspecs have been added to the logic.

Add another line to your .git/config for that remote that looks like this: fetch = ^refs/heads/X/*. You can find more details in this other answer.

Michael
  • 8,362
  • 6
  • 61
  • 88