1

my co-worker has just create a new branch in the git repository which we have been working for a while. but in my local repository, I am having a hard time to get the new branch and merge it into my local repos. I found this post: Only master branch is visible after cloning a Git repo, but it did not work for me.

  • when I try git branch -r, I don't see the new branch name listed,
  • when I try git fetch, it says no remote repos specified,
  • when I try git fetch newbranchname, it says newbranchname does not appear to be a repos,
  • when I try git chechout newbranchname, it says newbranchname did not match any file known to git.

what else can I try? please kindly help me, thanks a lot.

Community
  • 1
  • 1
bingjie2680
  • 7,643
  • 8
  • 45
  • 72

1 Answers1

3

The argument to git fetch is supposed to be a repository, not a branch.

$ git fetch origin
From https://github.com/...
 * [new branch]    newbranchname  -> origin/newbranchname

$ git checkout -b newbranchname origin/newbranchname
 Branch newbranchname set up to track remote branch newbranchname from origin.
 Switched to a new branch 'newbranchname'

You should now have a local copy of your coworker's branch from which you can git push and git pull to update.

vergenzt
  • 9,669
  • 4
  • 40
  • 47