Collection<VcsRef> (String @NotNull ... refs) { Collection<VcsRef> result = new ArrayList<>(); cd(getProjectRoot()); Hash hash = HashImpl.build(git("rev-parse HEAD")); for (String refName : refs) { if (isHead(refName)) { result.add(ref(hash, "HEAD", GitRefManager.HEAD)); } else if (isRemoteBranch(refName)) { git("update-ref refs/remotes/" + refName + " " + hash.asString()); result.add(ref(hash, refName, GitRefManager.REMOTE_BRANCH)); } else if (isTag(refName)) { git("update-ref " + refName + " " + hash.asString()); result.add(ref(hash, GitBranchUtil.stripRefsPrefix(refName), GitRefManager.TAG)); } else { git("update-ref refs/heads/" + refName + " " + hash.asString()); result.add(ref(hash, refName, GitRefManager.LOCAL_BRANCH)); } } setUpTracking(result); repo.update(); return result; }