Reputation: 7773
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.
git branch -r
, I don't see the new branch name listed, git fetch
, it says no remote repos specified,git fetch newbranchname
, it says newbranchname
does not appear to be a repos,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.
Upvotes: 1
Views: 430
Reputation: 10367
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.
Upvotes: 3