gpt4 book ai didi

git - 有人可以进一步解释用 git check out 远程分支吗?

转载 作者:太空狗 更新时间:2023-10-29 12:57:37 24 4
gpt4 key购买 nike

我在这里查看了几个问题,特别是这个 one但我还是很困惑。

我有一个服务器设置有一个慢速上行链路,我通过 SSH 隧道访问。在上面,我克隆了一个 Linux 内核的裸存储库(原点指向 kernel.org)。然后,我在我的家用机器上克隆了裸存储库, checkout 标签,创建了一个分支(比如“测试”),对该分支进行了更改,最后将更改推送到我服务器上的裸存储库。

现在我在客户站点并想检查分支机构。为了避免客户端站点上行速度变慢,我从 kernel.org 克隆了 linux 存储库,并将“来源”更改为通过 SSH 隧道指向我的服务器。 我可以看到分支,但无法查看:

~/linux-3.0.y$ git version
git version 1.7.0.4
~/linux-3.0.y$
~/linux-3.0.y$ git status
# On branch master
nothing to commit (working directory clean)
~/linux-3.0.y$
~/linux-3-0.y$ git remote show origin
git-user@localhost's password:
* remote origin
Fetch URL: git+ssh://git-user@localhost:48884/home/git-user/linux-3.0.y
Push URL: git+ssh://git-user@localhost:48884/home/git-user/linux-3.0.y
HEAD branch: master
Remote branches:
test new (next fetch will store in remotes/origin)
master new (next fetch will store in remotes/origin)
Local ref configured for 'git push':
master pushes to master (up to date)
~/linux-3.0.y$
~/linux-3.0.y$ git checkout -b test origin/test
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/test' which can not be resolved as commit?

我真正想要的是能够在我客户站点的家中创建的分支上工作。 我应该做什么(已经做了什么)来检查这个分支?

最佳答案

首先,您似乎没有获取分支。

使用 git branch -a 而不是 git remote show origin

如果缺少测试分支,则执行 git fetch --all

现在,如果您想将远程分支作为同名的本地分支 check out ,只需执行 git checkout BRANCH_NAME,它将自动设置为跟踪来源。

关于git - 有人可以进一步解释用 git check out 远程分支吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7335952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com