为什么我在 git 存储库中有两个主要分支?

Why do I have two main branches in git repo?

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

做了一个别名图

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

图表显示我有两个分支。所以,我决定合并主分支 origin/main

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

结帐时显示:您处于 'detached HEAD' 状态。

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 将列出所有远程存储库。

远程存储库有名称。经常为远程存储库选择“来源”。

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