[英]git branch not showing all branches
I have a github repository with 2 branches named master
and mobile
.我有一个 github 存储库,其中包含两个名为master
和mobile
的分支。 The mobile
branch is the default branch on GitHub, and this is the branch I am pushing to from my local directory as well. mobile
分支是 GitHub 上的默认分支,这也是我要从本地目录推送到的分支。
Whenever I have to push to remote, I have to enter the following command:每当我必须推送到远程时,我必须输入以下命令:
git push origin HEAD:mobile
I don't understand why I have to use the HEAD
word for it to work.我不明白为什么我必须使用HEAD
词才能工作。 When I don't use it, I get a refspec error.当我不使用它时,我会收到一个 refspec 错误。
When I checked the branches using git branch
, it only showed me * master
.当我使用git branch
检查分支时,它只显示了* master
。 I don't understand why it is not able to see the mobile
branch.我不明白为什么它看不到mobile
分支。
The output of git fetch is: git fetch 的输出是:
remote: Enumerating objects: 157, done.
remote: Counting objects: 100% (157/157), done.
remote: Compressing objects: 100% (111/111), done.
remote: Total 157 (delta 43), reused 154 (delta 42), pack-reused 0Receiving objects: 99% (156/157), 13.77 MiB | 9.01 MiB/s
Receiving objects: 100% (157/157), 14.22 MiB | 9.02 MiB/s, done.
Resolving deltas: 100% (43/43), done.
From https://github.com/myname/myreponame
* [new branch] master -> origin/master
The output of git branch --all -vv is: git branch --all -vv 的输出是:
* master f1881f6 cracker capture fixed
remotes/origin/master ccad84b Create README.md
remotes/origin/mobile f1881f6 cracker capture fixed
You have a remote mobile
branch, but that doesn't automatically give you a local mobile
branch.您有一个远程mobile
分支,但这不会自动为您提供本地mobile
分支。 You have to make one if you want one.如果你想要一个,你必须做一个。 You forgot to do that.你忘了这样做。 Thus all this time you've been working on master
but pushing to the remote mobile
.因此,这段时间你一直在master
上工作,但推送到远程mobile
。
To make a local mobile
based on the remote mobile
, say git switch mobile
.要基于远程mobile
制作本地mobile
,比如说git switch mobile
。
(Unfortunately that won't undo the damage you've done by pushing commits from your local master
to the remote mobile
. But it does explain completely the situation you've described in your question, namely why you didn't see any mobile
listed and why you had to say git push origin HEAD:mobile
.) (不幸的是,这不会消除您通过将本地master
提交到远程mobile
所造成的损害。但它确实完全解释了您在问题中描述的情况,即为什么您没有看到任何列出的mobile
以及为什么你不得不说git push origin HEAD:mobile
。)
通常推送到你的主分支只需要使用“git push”,但如果你使用另一个,那么应该是 git push origin (branch-name)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.