有人将称为 Git 推力源测试的分支推向共享仓库 。 我可以看到有 git 分支 -r 的分支 。 我如何查看远程测试分支 ? 我试过 :
git 检出测试, 它不会给 git 检出源/ 测试提供任何结果 * (无分支)
有人将称为 Git 推力源测试的分支推向共享仓库 。 我可以看到有 git 分支 -r 的分支 。 我如何查看远程测试分支 ? 我试过 :
git 检出测试, 它不会给 git 检出源/ 测试提供任何结果 * (无分支)
当前回答
git 远程显示 & lt; 原始名称 & gt; 命令将列出所有分支( 包括未跟踪的分支) 。 然后您可以找到要获取的远程分支名称 。
例如:
git remote show origin
使用这些步骤获取远程分支 :
git fetch <origin name> <remote branch name>:<local branch name>
git checkout <local branch name > (local branch name should the name that you given fetching)
例如:
git fetch origin test:test
git checkout test
其他回答
我尝试了上述解决方案,但行不通。试试这个,它奏效了:
git fetch origin 'remote_branch':'local_branch_name'
这将获取远程分支, 并创建一个新的本地分支( 如果尚未存在的话) , 名称为本地_ branch_ name , 并跟踪其中的远程分支 。
获得新创建的分支
git fetch
切换到另一个分支
git checkout BranchName
运行这两个命令,你应该可以去。
git checkout <branch-name>
git pull <remote> <branch-name>
在此情况下, 您可能想要创建一个本地测试分支, 跟踪远程测试分支 :
$ git branch test origin/test
在早期版本的 git 中, 您需要一个明确的 -- track 选项, 但是当您正在将远程分支分割出来时, 这是默认的 。
创建本地分支并切换到它,使用:
$ git checkout -b test origin/test
git 获取 -- all
将所有远程分支都带回您的本地
git 检出测试
将您切换到测试分支