Reputation: 270
Hello so I am working on an OS project and am trying to checkout someone else's branch.
Context:
What I've tried:
git checkout -b [otherDevelopersUsername]:[otherDevelopersBranch] upstream/[otherDevelopersUsername]:[otherDevelopersBranch]
but I get the following error:
fatal: 'upstream/[otherDevelopersUsername]:[otherDevelopersBranch]' is not a commit and a branch '[otherDevelopersUsername]:[otherDevelopersBranch]' cannot be created from it
What am I doing wrong? Thanks for the help.
edit:
git remote -vv
output
origin https://github.com/[myUsernam]/[repoName] (fetch)
origin https://github.com/[myUsername]/[repoName] (push)
upstream https://github.com/[OrgName]/[repoName] (fetch)
upstream https://github.com/[OrgName]/[repoName] (push)
Upvotes: 4
Views: 8346
Reputation: 1236
If the branch exists on another forked repo, you can obtain it as follows. Add the forked repo as another remote and checkout from it:
git remote add forked https://github.com/something/something.git
git fetch forked
git checkout -b otherDevelopersBranch forked/otherDevelopersBranch
git fetch
fetches any updates and new commits from the remote.
The checkout command will create a local branch that tracks the remote branch otherDevelopersBranch
on remote forked
Upvotes: 7
Reputation: 28944
If I'm understanding the question properly, the answer might be obvious.
You have two remotes:
origin
which is your fork of the repo.upstream
which is the original repo.And someone else made a PR, about which you state:
His draft pr is made from his forked repo to the main repo
The words "his forked repo" implies he has his own fork where his branch resides. In that case, you need a third remote pointing to his forked repo, in order to pull from it.
Upvotes: 2