2
$ git branch -a

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

What are their differences:

  • remotes/origin/HEAD

  • origin/main

  • remotes/origin/main

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
zell
  • 9,830
  • 10
  • 62
  • 115
  • 1
    useful [Why is there a remotes/origin/HEAD -> origin/master entry in my git branch -l -a output?](https://stackoverflow.com/questions/12613793/why-is-there-a-remotes-origin-head-origin-master-entry-in-my-git-branch-l/18746099) – Bn.F76 Mar 31 '21 at 19:55

1 Answers1

1

The remotes/origin/HEAD is the branch currently checked out in the origin repository, which means if you clone that repository, by default that branch will be checked out first.

The origin/main is a remote branch (which is a local copy of the branch named main on the remote named origin)

The remotes/origin/main, usually referred to as origin/main, is the location of a branch called main on the remote called origin the last time you did a git command. If they're related, main will have origin/main as its upstream.

Look at this question too: master vs. origin/master vs. remotes/origin/master

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
  • "*The `remotes/origin/HEAD` is the branch currently checked out in the `origin` repository*" Not exactly. The remote repository is almost always a bare repo and doesn't have any checked out branch. :-) – phd Nov 25 '20 at 00:02
  • 1
    "*The `origin/main` is a remote branch*" It's called remote-**tracking** branch and it's actually not a branch at all — it's a special kind of reference; it's moved by fetch/pull/push and cannot be committed to. – phd Nov 25 '20 at 00:04
  • 1
    `remotes/origin/main` and `origin/main` are synonyms; one is just the full name of the shorter other. You don't need 2 different paragraphs about them. :-) – phd Nov 25 '20 at 00:07