In the paper of Bonora et al. (2008) [3] we have shown, in the context of type II superstring theory, the classification of the allowed B-field and A-field configurations in the presence of anomaly-free D-branes, the mathematical framework being provided by the geometry of gerbes. Here we complete the discussion considering in detail the case of a stack of D-branes, carrying a non-abelian gauge theory, which was just sketched in Bonora et al. (2008) [3]. In this case we have to mix the geometry of abelian gerbes, describing the B-field, with the one of higher-rank bundles, ordinary or twisted. We describe in detail the various cases that arise according to such a classification, as we did for a single D-brane, showing under which hypotheses...