有人推了一个分行test
与git push origin test
共享仓库的共享仓库。git branch -r
如何查看遥控器test
我试过了
git checkout test
,它没有做任何事情git checkout origin/test
给给* (no branch)
有人推了一个分行test
与git push origin test
共享仓库的共享仓库。git branch -r
如何查看遥控器test
我试过了
git checkout test
,它没有做任何事情git checkout origin/test
给给* (no branch)
当前回答
我使用以下命令:
git checkout --track origin/other_remote_branch
其他回答
缩略git remote show <origin name>
命令将列出所有分支(包括未跟踪的分支)。然后您可以找到要获取的远程分支名称。
示例:
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 && git checkout --track origin/branch_name
git branch -r
表示对象名称无效, 因为该分支名称不在 Git 的本地分支列表中。 更新您的本地分支列表来源 :
git remote update
然后再试着检查一下你的远程分支
这对我管用
我相信git fetch
拉拉进全部( 全部)远端树枝,这不是最初的海报所要的。
你可以试试
git fetch remote
git checkout --track -b local_branch_name origin/branch_name
或
git fetch
git checkout -b local_branch_name origin/branch_name
您可以开始跟踪所有远程分支, 使用以下 Bash 脚本 :
#!/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 ;