1

I created a blank repo in github. It gets named as master.

In my local machine I did a git init and git clone of this repo.

Now when I do git branch -r I see

  origin/HEAD -> origin/master
  origin/master

From reading numerous articles and post my understanding is the following: origin/HEAD -> origin/master In above line origin/HEAD means currently checkout branch and -> origin/master means that it is pointed to master branch in remote (origin/ meaning remote)

However I think I might be thinking wrong, since I also read anything with origin/ to it represents remote since origin/ means remote.

So what is going on here, I am lost :(

Also why is there a second line saying origin/master again?

I read so many many posts and answers in SO and other sites but I am unable to make sense of this. Can any git gurus help me out here?

Undefined Variable
  • 4,196
  • 10
  • 40
  • 69
  • Run `git branch` *without* `-r`, or with `-a` (for "all"). Pay less attention to anything named `origin/` since those are just your Git's way of remembering some *other* Git's branches. – torek Sep 04 '18 at 22:04
  • Other than that, the place to start is with a good book on Git. There is a lot to learn! – torek Sep 04 '18 at 22:06

1 Answers1

0

git branch -r asks the question, "What remote branches do I know about?"

You're correct that origin/ represents a remote reference here, but it's just one remote reference--namely the repo from which you cloned your local repository. If you want to see other remotes you know about and where they point, run a git remote -v.

Focusing on just origin/master for a moment, this means that you know about a remote (named origin) that has a branch on it called master. You can even see commits on it if you do something like git log origin/master.

The first line origin/HEAD -> origin/master is a bit more complex, but means that, last you checked, the remote origin has the master branch checked out. See this answer for more discussion on what the HEAD pointer is.

Jeremy Fortune
  • 2,459
  • 1
  • 18
  • 21