gpt4 book ai didi

git - 我如何在git中切换分支?

转载 作者:行者123 更新时间:2023-12-05 01:58:44 27 4
gpt4 key购买 nike

我已经执行了下面的行来切换到我的队友创建的新分支:

git checkout with-backend

我收到以下错误:错误:pathspec 'with-backend' 不匹配 git 已知的任何文件

我尝试执行这个命令:

git branch -a

我的队友创建的with-backend 分支没有列出。下面是列出的结果:

* main
remotes/origin/HEAD -> origin/main
remotes/origin/main

最佳答案

首先,切换分支是用 git switch 完成的(自 Git 2.23,2019 年第三季度起),而不是 git checkout (它试图同时管理文件和分支,使其成为 confusing )

第二,git switch with-backend将在 git fetch 之后工作因为如果它的“猜测”模式:

If <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to

$ git switch -c <branch> --track <remote>/<branch>

关于git - 我如何在git中切换分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68356181/

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