有人将称为 Git 推力源测试的分支推向共享仓库 。 我可以看到有 git 分支 -r 的分支 。 我如何查看远程测试分支 ? 我试过 :
git 检出测试, 它不会给 git 检出源/ 测试提供任何结果 * (无分支)
有人将称为 Git 推力源测试的分支推向共享仓库 。 我可以看到有 git 分支 -r 的分支 。 我如何查看远程测试分支 ? 我试过 :
git 检出测试, 它不会给 git 检出源/ 测试提供任何结果 * (无分支)
当前回答
工作命令
git 获取源“ remote_ branch ” : “ 本地_ branch_ name” git开关 “ 本地_ branch_ name” git pull 源“ remote_ branch ” : “ 本地_ branch_ name ”
第一个是从远程分支获取分支和创建本地分支。
第二个是转换到当地分行。
第三是将最近的远程更改拖到本地分支。
其他回答
i 使用以下命令:
git checkout --track origin/other_remote_branch
被接受的答案不为你工作?
第一个和选定答案在技术上是正确的,但您可能尚未从远程仓库中检索到所有对象和参考文献。 如果是这样,您将会收到以下错误:
$ git checkout -b remote_branch origin/remote_branch
致命: git 检出: 更新路径与切换分支不兼容 。 您是否打算检查“ 来源/ remote_ branch ” , 无法以承诺方式解决 ?
解决方案
如果您收到此信件, 您必须先从 Git 获取源代码中获取消息, 在运行 git 检查远程_ branch 之前, 源代码是远程仓库的名称 。 以下为完整的例子, 并给出回复 :
$ git fetch origin
remote: Counting objects: 140, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 69 (delta 36), reused 66 (delta 33)
Unpacking objects: 100% (69/69), done.
From https://github.com/githubuser/repo-name
e6ef1e0..5029161 develop -> origin/develop
* [new branch] demo -> origin/demo
d80f8d7..359eab0 master -> origin/master
$ git checkout demo
Branch demo set up to track remote branch demo from origin.
Switched to a new branch 'demo'
正如您所看到的, 运行 Git 抓取来源时, 检索到我们尚未设置的远程分支 来追踪本地机器 。 从那里, 既然我们现在有一个 ref 到远程分支, 我们可以简单地运行 git 检查远程支架, 我们会从远程跟踪中受益 。
要获得所有远程分支, 请使用这个 :
git fetch --all
然后检查到分支 :
git checkout test
i 使用了这一个:
git clean -fxd # removes untracked (new added plus ignored files)
git fetch
git checkout {branchname}
git reset --hard origin/{branchname} # removes staged and working directory changes
使用抓取来拉动全部远程
git fetch --all
列表远程分支 :
git branch -r
列表所有您的分支
git branch -l
>>outpots like-
* develop
test
master
要取出/更改分支
git checkout master