2

I have just done :

git fetch origin feature/myfeature

I would expect to see in my local branches when I issue:

git branch

But strangely I cannot see the fetched branch, which was successful. Am I misunderstanding something?

TrueWill
  • 25,132
  • 10
  • 101
  • 150
SamJolly
  • 6,347
  • 13
  • 59
  • 125

4 Answers4

2

Can you use git show-branch --all?! All detail are here: https://git-scm.com/docs/git-show-branch

Kenny Tai Huynh
  • 1,464
  • 2
  • 11
  • 23
  • 1
    I made a mistake in fetching. I am now seeing the branch. Thanks to all. – SamJolly Aug 15 '16 at 14:24
  • Not quite fixed I am afraid. I have noted that if I do a fetch, I do not see the branch. When I checkout the branch I then see it. Do you know to checkout to new fetched branch before it become visible? – SamJolly Aug 15 '16 at 15:09
  • 1
    I'm not really sure. But can you try this http://stackoverflow.com/questions/11623862/git-fetch-doesnt-fetch-all-branches – Kenny Tai Huynh Aug 15 '16 at 15:33
  • Ok, Thanks, will checkout – SamJolly Aug 15 '16 at 15:34
  • 1
    Also get Feature/MyFeature-> FETCH_HEAD as opposed to Feature/MyFeature -> Feature/MyFeature which I have seen where it has worked – SamJolly Aug 15 '16 at 15:37
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/120977/discussion-between-kenny-tai-huynh-and-samjolly). – Kenny Tai Huynh Aug 15 '16 at 15:40
1

Because git branch shows only local branches. Use git branch -a to see both local and remote branches or git branch -r to see only remote branches

Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116
1

From git's manual:

If --list is given, or if there are no non-option arguments, existing branches are listed; the current branch will be highlighted with an asterisk. Option -r causes the remote-tracking branches to be listed, and option -a shows both local and remote branches.

Michał Walenciak
  • 4,257
  • 4
  • 33
  • 61
1

While fetching you can specify a branch that should be created locally

git fetch origin <remote_branch>:<local_branch> 

When fetching, all the branches should be visible when you issue git branch -a or git branch -r

mic4ael
  • 7,974
  • 3
  • 29
  • 42