Reputation: 7228
I have a local repo that tracks a remote repo in Visual Studio Team Services (VSTS) and currently is in branch master. A colleague has pushed a new feature branch to the remote. I want to pull that remote and switch to it. I've tried the following:
git pull
git pull --all
git branch
does not show the new remote branch locally. I also tried
git checkout -b FeatureBranch origin/FeatureBranch
but I get this error:
fatal: Cannot update paths and switch to branch 'FeatureBranch' at the same time.
Did you intend to checkout 'origin/FeatureBranch' which can not be resolved as commit?
Also tried
git checkout --track origin/FeatureBranch
which I think is the same as the previous command and get the same error. Any ideas what I'm doing wrong?
git status
gives
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
Upvotes: 0
Views: 126
Reputation: 38639
pull
only fetches the to-be integrated remote branch. You should use fetch
instead to update all remote tracking branches in your local repository with the brnaches from the remote. After that your command should work and git branch -a
or git branch -r
will show that branch. Also after it is fetched, if it is not present in multiple remotes, you can even simply do git checkout FeatureBranch
and it will implicitly do the same as git checkout -b FeatureBranch origin/FeatureBranch
, except you are using an ancient Git version.
Upvotes: 1