微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么我在 git repo 中有两个主要分支?

如何解决为什么我在 git repo 中有两个主要分支?

有人能解释一下这里发生了什么吗?为什么有两个主要分支,一个名为“origin/main”,另一个名为“main”

制作别名图

DRB@SamiUllah MINGW64 /d/30days_python/myscrapping (main)
$ alias graph="git log --all --decorate --oneline --graph

图表显示我有两个分支。所以,我决定将主分支与 起源/主要

DRB@SamiUllah MINGW64 /d/30days_python/myscrapping (main)
$ graph
* 593f35d (HEAD -> main) Reorganized files of this repo
* 92fbed4 (origin/main) First commit from local repo
* eaf216d Initial commit

结帐时,它说:您处于“分离头”状态。

DRB@SamiUllah MINGW64 /d/30days_python/myscrapping (main)
$ git checkout origin/main
Note: switching to 'origin/main'.

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 92fbed4 First commit from local repo

DRB@SamiUllah MINGW64 /d/30days_python/myscrapping ((92fbed4...))
$ git checkout main
PrevIoUs HEAD position was 92fbed4 First commit from local repo
Switched to branch 'main'

解决方法

origin 是远程存储库。

git remote -v 将列出所有远程存储库。

远程仓库有名字。通常为远程存储库选择“来源”。

您看到两个主要分支,因为 - 远程存储库和您的本地存储库具有相同的分支

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。