Use the git-branch command to get all branches and their hashes

This is safer than directly enumerating the files, since git creates a file of
the name {branch-name}.lock to lock {branch-name}, and the existing code did not
handle this correctly. Going through "git branch" is safer because we know it
will ignore these lock files and respect any locks that may be held.