0

I'm clearly missing something since I am unable to fetch the remote branch I need on the server from the git repo I've been working with locally.

On my local dev environment

I run git remote -v and it gives me:

origin  git@git.example.com:the_repo (fetch)
origin  git@git.example.com:the_repo (push)

I run git branch and it gives me:

* live
  master

On my live server environment

I run git remote -v and it gives me:

origin  git@git.example.com:the_repo (fetch)
origin  git@git.example.com:the_repo (push)

I run git branch and it gives me:

* master

When I try to fix this situation by running git fetch or git fetch origin, I still do not see my live branch upon running git branch again. I suspect this is because git branch only lists my local branches.

How can I fetch the repo's remote branches and list them before I check them out locally?

Many thanks - much appreciated.

Blake Frederick
  • 1,510
  • 20
  • 31

3 Answers3

2

You can use the command git branch -r to see remote branches.

Matt Harper
  • 122
  • 8
2

Matt's answer is correct, but just to add:

git branch -a

will display "all" branches, both local and remote.

CodingWithSpike
  • 42,906
  • 18
  • 101
  • 138
0

Matt and CodingWithSpike's responses both work for my purposes (thanks). Additionally, I've just found that the git branch -vv command displays which local branches are associated with which remote branches.

Blake Frederick
  • 1,510
  • 20
  • 31