Git没有显示本地服务器上的所有分支
我从Github获得了回购协议。执行Git没有显示本地服务器上的所有分支,git,github,moodle,git-remote,Git,Github,Moodle,Git Remote,我从Github获得了回购协议。执行git remote-v时,它会显示: origin https://github.com/myusername/moodle.git (fetch) origin https://github.com/myusername/moodle.git (push) upstream https://github.com/moodle/moodle.git (fetch) upstream https://github.com/moodle/mood
git remote-v
时,它会显示:
origin https://github.com/myusername/moodle.git (fetch)
origin https://github.com/myusername/moodle.git (push)
upstream https://github.com/moodle/moodle.git (fetch)
upstream https://github.com/moodle/moodle.git (push)
moodle.git大约有10个分支,但回购协议只显示了其中的2个。在执行git分支-a
(显示所有分支)时,我得到:
如何在不丢失任何数据或不规则的情况下解决我的问题?克隆一个repo不会复制本地repo上的所有远程分支:对于一个有很多分支的大型远程repo,这会用大量分支污染您的本地命名空间 为了创建跟踪远程回购的所有远程分支的本地分支,我有一个目标,但这通常是不需要的。
仅在需要时创建跟踪远程分支的本地分支
git checkout -b aBranch --track origin/aBranch
# or, shorter:
$ git checkout --track origin/aBranch
Branch aBranch set up to track remote branch refs/remotes/origin/aBranch.
Switched to a new branch "aBranch"
# even shorter at the end of this answer.
添加一个--track
允许设置配置,将起点分支从新分支标记为“”。此配置将告诉git在
git状态
和git分支-v
中显示两个分支之间的关系此外,当签出新分支时,它会在没有参数的情况下指示git pull从上游进行拉取
提到在从远程分支分叉分支时暗示了
--track
(除非branch.autosetupmerge
设置为false
)
这就足够了
git checkout aBranch
确切的解释是:
如果未找到具有匹配名称的
,但在一个遥控器(称之为
)中确实存在跟踪分支,则视为等同于:
$git checkout-b--track/有时,如果您没有提取最新的代码,就不允许签出新创建的分支。因为您的更改不同步
所以首先
-最新消息
-从新创建的分支机构签出为什么您希望有更多的本地分支机构?克隆存储库后,只有一个本地主分支。其他分支是根据需要创建的。@knittl:好的。我不知道。你能告诉我怎么做吗?我已经创建了一个分支,比如说git checkout-b STABLE\u 23\u STABLE
,但文件不是该分支的文件。git checkout-b MOODLE\u 23\u STABLE
在当前提交的基础上创建了一个新分支,因此您仍然会看到相同的提交。当从远程分支分叉分支时,git checkout-b MOODLE_23_STABLE up/MOODLE_23_STABLE
或git checkout MOODLE_23_STABLE
(速记/DWIM语法)--track
的重复(除非branch.autosetupmerge
未设置为false
)。我还建议@xan,慢慢来,读一些书,以后不要迷路。@kostix说得对。我在答案中添加了这种精度,以提高可见性。git checkout——跟踪原点/aBranch
这为我解决了这个问题,谢谢
git checkout aBranch
$ git checkout -b <branch> --track <remote>/<branch