有人将称为 Git 推力源测试的分支推向共享仓库 。 我可以看到有 git 分支 -r 的分支 。 我如何查看远程测试分支 ? 我试过 :
git 检出测试, 它不会给 git 检出源/ 测试提供任何结果 * (无分支)
有人将称为 Git 推力源测试的分支推向共享仓库 。 我可以看到有 git 分支 -r 的分支 。 我如何查看远程测试分支 ? 我试过 :
git 检出测试, 它不会给 git 检出源/ 测试提供任何结果 * (无分支)
当前回答
被接受的答案不为你工作?
第一个和选定答案在技术上是正确的,但您可能尚未从远程仓库中检索到所有对象和参考文献。 如果是这样,您将会收到以下错误:
$ 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 获取源“ remote_ branch ” : “ 本地_ branch_ name” git开关 “ 本地_ branch_ name” git pull 源“ remote_ branch ” : “ 本地_ branch_ name ”
第一个是从远程分支获取分支和创建本地分支。
第二个是转换到当地分行。
第三是将最近的远程更改拖到本地分支。
请遵循命令创建空文件夹。 请输入并使用此命令 :
saifurs-Mini:YO-iOS saifurrahman$ git clone your_project_url
Cloning into 'iPhoneV1'...
remote: Counting objects: 34230, done.
remote: Compressing objects: 100% (24028/24028), done.
remote: Total 34230 (delta 22212), reused 15340 (delta 9324)
Receiving objects: 100% (34230/34230), 202.53 MiB | 294.00 KiB/s, done.
Resolving deltas: 100% (22212/22212), done.
Checking connectivity... done.
saifurs-Mini:YO-iOS saifurrahman$ cd iPhoneV1/
saifurs-Mini:iPhoneV1 saifurrahman$ git checkout 1_4_0_content_discovery
Branch 1_4_0_content_discovery set up to track remote branch 1_4_0_content_discovery from origin.
Switched to a new branch '1_4_0_content_discovery'
git 获取\ \ \ git 检查您的处名
tl; dr , tl; dr
使用 git 开关而不是 git 检出。 更多详情请见此页面 。
我认为答案已经过时。 git 将一些退票功能分割为切换和现在恢复 。
以下是我的总结:
如果您想要为远程分支更新一些内容, 您应该创建一个本地分支以“ 跟踪” 远程分支。 您可以在本地更新任何您想要更新的内容, 并最终推到远程 。 如果您在克隆您的仓库后直接检查到远程分支, 您可能会看到“ 标记头” 状态, 并从 git 中看到以下信息 :
Note: switching to 'origin/asd'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at d3e1083 Update a
如何建立本地分支跟踪远程分支?
要创建本地分支以跟踪远程分支, 您可以使用 git checkout & lt; remote 分支名 & gt; 或 git 开关 < remote 分支名 & gt; 。 如果您有一个文件或文件夹与您的远程分支名有相同名称, git checkout 会输出一些错误消息, 但是 git 开关通常可以正常工作 。
例如:
查看所有分支, 我们想要创建一个本地分支, 以跟踪远程分支遥控器/ 原发/ ass 。 我们也有一个文件名称 : $ git 分支 - a * 主遥控器/ 原发/ 头发- & gt; 原发/ 主遥控器/原发/ 原发/ 远地/ 原发/ 原发/ 原发/ zxc $ 。 以文件名和文件名相同 。 如果我们使用 Git 检查命令创建本地分支以跟踪远程分支 $ git 检查结果, git 则应该输出一些错误信息 。
我不确定 我日复一日地干这个 下个命令就像宝石一样
成为你要退房的分行
git fetch && git checkout dev