0

When I type

git branch -avv

it shows me the list of all branches: local and remote ones

git branch -avv
  master                   2fa4d6c [origin/master] RT92026 Modified 'update' for the STM32F429 Discovery to use 'image'. Removed 'eimage'.
  remotes/origin/HEAD      -> origin/master
  remotes/origin/master    2fa4d6c RT92026 Modified 'update' for the STM32F429 Discovery to use 'image'. Removed 'eimage'.
  remotes/origin/zpm       37aadc6 Change bootargs to use rootfs at mtdblock2
  remotes/origin/zpm_16MB  1f82630 fixed error in macro concatenations with just hardcoded values
  remotes/origin/zpm_dev   115d973 changed CONFIG_LPC178X_PLL0_PSEL to 1
  remotes/origin/zpm_pulse cd2f813 changes for 16MB RAM

The question is - can I get remote branch remotes/origin/zpm_pulse if remote repository is not available anymore and I have only local copy? (no branch was set to origin/zpm_pulse).

So when I create a local branch zpm_pulse and bind it to upstream one it says:

2fa4d6c [origin/zpm_pulse: behind 27] RT92026 Modified 'update' for the STM32F429 Discovery to use 'image'. Removed 'eimage'.

And after that of course I can't fetch from origin because origin is no more. So maybe git stores remote branches somewhere inside?

pulse
  • 303
  • 4
  • 18
  • You write: *can I get remote branch `remotes/origin/zpm_pulse` [...]*. What exactly do you mean by "get", in that sentence? *Check it out*? You should know that `origin/zpm_pulse` is a remote-tracking branch, i.e. a special type of a local branch that represents a copy of a branch that lives (or once lived) in a remote repo. Therefore, you can always *check it out* as a local branch in your own repo: `git checkout -b zpm_pulse origin/zpm_pulse`. Is that what you want to do? – jub0bs Mar 09 '15 at 14:08
  • Yeah, I found how stupid I was after some time. `git checkout -b zpm_pulse remotes/origin/zpm_pulse` worked fine for me. Thank you! – pulse Mar 09 '15 at 14:17
  • possible duplicate of [Checkout remote Git branch](http://stackoverflow.com/questions/1783405/checkout-remote-git-branch) – jub0bs Mar 09 '15 at 14:21
  • What was wrong is when I did `git push -u origin --all` only local branches were pushed. After that I did `git push origin --mirror` but still didn't find any new branches. So I thought they are lost ;) – pulse Mar 09 '15 at 14:22

1 Answers1

0

You write

So when I create a local branch zpm_pulse and bind it to upstream one it says:

2fa4d6c [origin/zpm_pulse: behind 27] RT92026 Modified 'update' for the STM32F429 Discovery to use 'image'. Removed 'eimage'.

This means that there already is a local branch named zpm_pulse which is 27 commits behind origin/zpm_pulse. Simply fast-forward merge the remote branch and you have all changes up to and including commit cd2f813:

git merge --ff-only origin/zpm_pulse
knittl
  • 246,190
  • 53
  • 318
  • 364