Search code examples
gitgithubgit-remoteupstream-branch

How to checkout to another remote in GitHub?


I'm using two repositories on github named as origin and upstream.

I can checkout to different branch with git checkout [branch-name] only within origin.

I cannot checkout to another repo upstream.

I have used -t option but it didn't work.

The error message was:

'upstream/[branch-name]' is not a commit and a branch '[branch-name]' cannot be created from it

I've added two repositories as my remote.

How do I solve this problem?


Solution

  • Try a git fetch upstream, followed by git branch -avv.

    If you don't see branch_name (the branch you want to checkout from upstream), then double-check the refspec associated with upstream:

    git config --local -l
    

    You should see:

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

    If not, that would explain why you don't fetch all the branches from upstream.