Can not create a local and remote branch (tracking) at the same time

不羁的心 提交于 2019-12-05 01:38:27
VonC
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.

Seems like you hadn't fetch that commit yet. So, first do:

git fetch origin

And then:

git checkout --track origin/iss53

FWIW for other people with the same error message: when this happened to me, the underlying problem was that I was trying to make a branch with spaces in the name. For the set of pre-canned GIT commands I had, branches with spaces were a problem.

(ObDisclaimer: I am very, very far from a git expert. I just know that I had a problem with an identical error message, and the solution was different than the accepted answer)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!