当前位置:   article > 正文

git checkout 远程分支失败的问题解决_hbuilderx切换到远程分支一直失败

hbuilderx切换到远程分支一直失败

##今天git checkout -b xxx origin/yyy 远程分支失败了,报错:

fatal: Cannot update paths and switch to branch ...
  • 1

解决方法

git fetch -p
  • 1

然后重新:

git checkout ...
  • 1

-p的意思

When you fetch a remote repository, say “origin”, you will get remote branches for each branch that exists on that remote repository. Those branches are locally stored as /.

So assume origin has branches master, featureX and featureY. Then after fetching the following “remote branches” exist in your local repository: origin/master, origin/featureX and origin/featureY.

Now, imagine someone else merges featureX into master and removes the feature branch from the remote repository. Then origin only has two branches master and featureY.

However, when you fetch, the three remote branches will all still exist, including the one that was deleted in the remote repository. This is to prevent you from accidentally losing the branch (imagine someone accidentally removed the branch from the remote, then everyone who fetched from it would also lose it, making it hard to restore it).

Instead, you will need to tell the fetch command to prune any branches that no longer exist on the remote branch. So by executing git fetch –prune origin or git fetch -p the remote branch origin/featureX will be removed too.

Btw. if you want to remove a branch from a remote repository, you will have to push an “empty” branch to it, e.g. git push origin :branchname will remove the remote branch origin/branchname both locally and on the remote itself.
详见stackoverflow,the first answer.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/586761
推荐阅读
相关标签
  

闽ICP备14008679号