2

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?

Hugo y
  • 1,421
  • 10
  • 20
jin yun
  • 23
  • 3
  • does [branch-name] exist in upstream, or are you trying to create it – jdow May 14 '19 at 04:10
  • try `git fetch upstream` and after that `git branch -a`. You should see your upstream branch as **upstream/[branch_name]** in the list. Then you can checkout to that with `git checkout upstream/[branch_name]` – rupj May 14 '19 at 06:45

1 Answers1

1

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250