hub checkout pull request when fork is deleted #473

ivantsepp opened this Issue Feb 1, 2014 · 2 comments

3 participants


Recently I tried to checkout a pull request and the fork was deleted:

jekyll[master] $ hub checkout
Error: troyswanson's fork is not available anymore

I recently saw a talk and found out that Github stashes the pull requests on the repo so that I could do this instead:

jekyll[master] $ git fetch origin pull/1869/head:so-long-excerpt
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 12 (delta 1), reused 6 (delta 1)
Unpacking objects: 100% (12/12), done.
 * [new ref]         refs/pull/1869/head -> so-long-excerpt

Maybe we could change hub's checkout command so that if fork doesn't exist, it'll take the above route to fetch the pull request. Not sure how to reveal the two different paths of "checkout" to the user.

GitHub member

It's a good idea. I actually have done this in a branch already months ago, but it was never polished or well tested enough to share. I was meaning to switch everything to refs/pull/XY instead of having two different code paths.

This is still on my radar. I'll leave this open until we decide on a move in this direction.

Thanks for the great suggestions lately 😍


@ivantsepp thanks for opening this - just helped me with a pull request whose fork had been deleted and worked like a charm.

One thing that was unclear to me from reading this: in git fetch origin pull/1869/head:so-long-excerpt, so-long-excerpt should be the name of a new branch, not an existing branch.

Hope that helps someone else :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment