From Pro Git:
you can set up other tracking branches if you wish — ones that don’t track branches on origin and don’t track the master branch. The simple case is the example you just saw, running git checkout -b [branch] [remotename]/[branch]
$ git checkout --track origin/serverfix Branch serverfix set up to track remote branch refs/remotes/origin/serverfix. Switched to a new branch "serverfix"
$ git checkout -b sf origin/serverfix Branch sf set up to track remote branch refs/remotes/origin/serverfix. Switched to a new branch "sf"
My understanding is that this presents a way to create a local branch and an upstream branch.
But when I do:
git checkout -b iss53 origin/iss53
I get:fatal: Cannot update paths and switch to branch 'iss53' at the same time.
And when I do:git checkout --track origin/iss53
I get:
fatal: Cannot update paths and switch to branch 'iss53' at the same time. Did you intend to checkout 'origin/iss53' which can not be resolved as commit?
Why?
Cannot update paths and switch to branch
As I mention in "Get new upstream branch with git", you can try:
# let's create a new local branch first
git checkout -b iss53
# then reset its starting point
git reset --hard origin/iss53
Make sure that the remote tracking branch origin/iss53
does exist first (after a git fetch origin
)
origin/iss53
means there was a iss53
on the upstream remote repo referenced by origin
.
If there was not such a branch, then you only create a local branch iss53
, and push it like so:
git push -u origin iss53
That would establish an association between the local branch iss53
and the remote tracking branch origin/iss53
(tracking the newly created branch iss53
on origin
, created by the push).
See "Why do I need to explicitly push a new branch?" for more on that initial push.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With