Git:如何 checkout 新的远程分支?

标签 git github branch git-checkout git-remote

我正在尝试检查本地不存在的远程分支。

git checkout -b branch_name origin/branch_name

给出:

fatal: Cannot update paths and switch to branch 'branch_name' at the same time.
Did you intend to checkout 'origin/branch_name' which can not be resolved as commit?

git branch -a 没有显示我正在尝试 checkout 的分支。

如何在本地 checkout 远程分支?

最佳答案

试试这个

git remote update
git fetch
git checkout -b branch_name origin/branch_name

您的本地仓库不知道远程分支。

关于Git:如何 checkout 新的远程分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31286881/

相关文章:

git 2018 : Is there a way to rename a branch at remote for all users?

git - 无法在笔记本电脑上克隆 git 存储库,但是在开发机器上成功克隆

git - 如何在我的 NetBeans IDE 中设置 github 存储库?

Mercurial 将一个分支设置为新的默认分支

version-control - 能否/应该避免频繁 merge (例如通过 rebase )?

git - 对在 git 中创建嵌套分支感到困惑

c# - 使用 Git 和 Visual Studio 检查项目

git - 将 git 存储库中的文件夹拆分为单独的分支

github - 新的 GitHub 操作在空文件夹中运行

git - 为什么我不能在 docker 中使用正确的 ssh key 克隆私有(private) git 存储库?