private boolean isLocalBranch(Git git, String branch) throws GitAPIException { List<Ref> branches = git.branchList().call(); for (Ref ref : branches) { if (Repository.shortenRefName(ref.getName()).equals(branch)) return true; } return false; }