Git:无法切换到新的远程分支

标签 git github branch git-branch

我在 github 上有一个帐户,我在两台不同的机器上使用它。一方面,我创建了一个新分支 myNewBranch 并切换到它。然后我对我的代码进行了修改,我提交并推送myNewBranch

在第二台机器上,我不知道如何推送。

$ git pull origin myNewBranch
From https://github.com/myUsername/myProject
 * branch            myNewBranch -> FETCH_HEAD
Already up-to-date.

[我已经成功从中 pull 出]

然后我尝试切换到它,但出现错误:

$ git checkout myNewBranch
error: pathspec 'myNewBranch' did not match any file(s) known to git.

我错过了什么?

最佳答案

您需要先将数据提取到机器 2 上的本地存储库中:

$ git fetch origin
$ git checkout origin/myNewBranch

关于Git:无法切换到新的远程分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16846115/

相关文章:

git - 使用 shell 函数时无法添加 git 别名

git - Git LFS 是否支持本地或 "near"二级存储/缓存?

GIT 仅 pull 项目文件而不 pull LFS 模块

github - 如何构建GitHub Wiki文件?

git - 为什么 GitHub 不是 Azure Web App 部署的选项?

git - 如何从当前分支获取git父分支名称?

git - 如何覆盖 .gitignore 中的规则集

github - Cloud Build 触发器设置包含陈旧、过时的 GitHub 分支数据

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

git - 然后我在本地删除了一个分支为什么这个分支在github上仍然有效