Style-nit: We don't use { } around the statements when there is only one statement being nested.

I would also put a blank line before each else if to make the code more readable:

  if (ref.getName().startsWith(Constants.R_HEADS))
    branches.add(...);

  else if (ref.getName().startsWith(Constants.R_REMOTES))
    remoteBranches.add(...);