1

I'm a bit stranded with github: I forked a repository on github a while ago and made up a new branch on my Notebook. I did some changes and then a pull request. Unfortunately my Notebook got broken and now I want to commit some changes into the PR from a new Computer. How do I get in my old branch, so that I just have to add/commit/push for the same PR from my new Computer?

I tried git fetch --all, but my branch isn't there.

\edit: I just delete the cloned fork and recloned it and then doing the steps written down here and it works.

  • I think something is missing here. How did the code base find its way onto your new computer in the first place? – Tim Biegeleisen Apr 10 '20 at 04:07
  • Ah sorry, i just cloned my forked repo onto my new Computer –  Apr 10 '20 at 13:12
  • @Droelfeindrittel yes, and I have explained below how to fetch your PR branch into your local cloned repository. – VonC Apr 10 '20 at 14:00

1 Answers1

1

In your new computer, you can checkout a pull request locally:

 git fetch origin pull/ID/head:BRANCHNAME
 git switch BRANCHNAME

The reason a normal fetch has not fetched your PR branch is because of the default refspec.

remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

That would not fetch the pull/xx namespace.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `git fetch origin pull/ID/head:BRANCHNAME` didn't work, it says " can't find remote reference puu/ID/head" but it works when i delete everything and re-clone the forked repo. –  Apr 10 '20 at 14:56
  • @Droelfeindrittel You did replace "ID" by the actual number of your PR, didn't you? – VonC Apr 10 '20 at 15:05
  • @Droelfeindrittel You mentioned puu/ID: was it a typo? It should be pull/ID. https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/checking-out-pull-requests-locally does work. – VonC Apr 10 '20 at 16:38