Remote Branches

Goals

  • Learn about local VS remote branches

Let’s look at the branches available in our cloned repository.

Execute:

  1. git branch

Output:

  1. $ git branch
  2. * master

That’s it, only the master branch is listed. Where is the greet branch? The git branch command only lists the local branches by default.

List Remote Branches

Try this to see all the branches:

Execute:

  1. git branch -a

Output:

  1. $ git branch -a
  2. * master
  3. remotes/origin/HEAD -> origin/master
  4. remotes/origin/greet
  5. remotes/origin/master

Git has all the commits from the original repository, but branches in the remote repository are not treated as local branches here. If we want our own greet branch, we need to create it ourselves. We will see how to do that in a minute.