diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 472adf41eb..beba889f5f 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -765,6 +765,8 @@ public GHRef[] getRefs(String refType) throws IOException { * invalid ref type being requested */ public GHRef getRef(String refName) throws IOException { + // hashes in branch names must be replaced with the url encoded equivalent or this call will fail + refName = refName.replaceAll("#", "%23"); return root.retrieve().to(String.format("/repos/%s/%s/git/refs/%s", owner.login, name, refName), GHRef.class).wrap(root); } /**