有人将称为 Git 推力源测试的分支推向共享仓库 。 我可以看到有 git 分支 -r 的分支 。 我如何查看远程测试分支 ? 我试过 :

git 检出测试, 它不会给 git 检出源/ 测试提供任何结果 * (无分支)


当前回答

您可以在本地端添加新的分支测试,然后使用:

git branch --set-upstream-to=origin/test test

其他回答

i 使用以下命令:

git checkout --track origin/other_remote_branch

从远程获取并检查分支 。

git fetch <remote_name> && git checkout <branch_name> 

例如:

git 获取来源 git 检出功能/xyz-1234 - 添加警报

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 checkout -b feature/branch remotes/origin/feature/branch

您可以开始跟踪所有远程分支, 使用以下制表单脚本 :

#!/bin/bash
git fetch --all
for branch in `git branch -r --format="%(refname:short)" | sed 's/origin\///'`
  do git branch -f --track "$branch" "origin/$branch"
done

这里还有一个单行版本 :

git fetch --all; for branch in `git branch -r --format="%(refname:short)" | sed 's/origin\///'`; do git branch --track "$branch" "origin/$branch" ; done ;