How do I fetch a branch on someone else's fork on GitHub?


I’ve forked from a repo on GitHub. I want to get the code from a branch on another user’s fork.

Must I clone this user’s whole repo to a separate local repo or can I do something like git checkout link_to_the_other_users_branch?


$ git remote add theirusername [email protected]:theirusername/reponame.git
$ git fetch theirusername
$ git checkout -b mynamefortheirbranch theirusername/theirbranch

Note that there are multiple "correct" URIs you can use for the remote when you add it in the first step.

  • [email protected]:theirusername/reponame.git is an SSH-based URI
  • is an HTTPS URI

Which one you prefer to use will depend on your situation. GitHub has a help article explaining the difference and helping you choose: Which remote URL should I use?

Answered By – amalloy

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published