Search This Blog

Saturday, May 18, 2013

How to checkout Nova Folsom or Grizzly branch on github

Since Openstack Folsom release the source code is tracked on github. The previous releases like Essex, Diablo ... were maintained on Canonical Launchpad.

https://launchpad.net/nova/essex
https://github.com/openstack/nova

Problem

How to checkout Folsom release

Solution

We start with checking out latest nova code.
 
git clone git://github.com/openstack/nova.git
Cloning into 'nova'...
remote: Counting objects: 174497, done.
remote: Compressing objects: 100% (40106/40106), done.
remote: Total 174497 (delta 140401), reused 164045 (delta 130984)
Receiving objects: 100% (174497/174497), 116.95 MiB | 2.01 MiB/s, done.
Resolving deltas: 100% (140401/140401), done.

We can see what branches are available.
 
cd nova
 git branch
* master

At first it looks like something went wrong. We can see some tags although.
 
git tag
0.9.0
2011.1rc1
2011.2
...

To see all the branches (local and remote) we need to use -r or -a options.
 
git branch -r
  origin/HEAD -> origin/master
  origin/master
  origin/stable/folsom
  origin/stable/grizzly

git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/stable/folsom
  remotes/origin/stable/grizzly

When combining with -v we can see the last commits ID. We see that local master is the same as remotes/origin/master.
 
git branch -v -a
* master                        e4f05ba Imported Translations from Transifex
  remotes/origin/HEAD           -> origin/master
  remotes/origin/master         e4f05ba Imported Translations from Transifex
  remotes/origin/stable/folsom  6740c41 Check QCOW2 image size during root disk creation
  remotes/origin/stable/grizzly 159fdd2 Merge "Detach volume fails when using multipath iscsi"

We can see more info about the remote branch.
 
 git remote -v show origin
* remote origin
  Fetch URL: git://github.com/openstack/nova.git
  Push  URL: git://github.com/openstack/nova.git
  HEAD branch: master
  Remote branches:
    master         tracked
    stable/folsom  tracked
    stable/grizzly tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

To checkout a remote branch we use the standard checkout with -b options.
 
git checkout -b folsom  remotes/origin/stable/folsom
Checking out files: 100% (2510/2510), done.
Branch folsom set up to track remote branch stable/folsom from origin.
Switched to a new branch 'folsom'

git branch -a
* folsom
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/stable/folsom
  remotes/origin/stable/grizzly

 git branch -a -v
* folsom                        6740c41 Check QCOW2 image size during root disk creation
  master                        e4f05ba Imported Translations from Transifex
  remotes/origin/HEAD           -> origin/master
  remotes/origin/master         e4f05ba Imported Translations from Transifex
  remotes/origin/stable/folsom  6740c41 Check QCOW2 image size during root disk creation
  remotes/origin/stable/grizzly 159fdd2 Merge "Detach volume fails when using multipath iscsi" into stable/grizzly

As you can see it created a new local branch and set the pointer to the remote one. There is another way as well to do the same. We use the Grizzly branch to demonstrate this.
 
git checkout --track remotes/origin/stable/grizzly
Checking out files: 100% (2355/2355), done.
Branch stable/grizzly set up to track remote branch stable/grizzly from origin.
Switched to a new branch 'stable/grizzly'

git branch -a -v
  folsom                        6740c41 Check QCOW2 image size during root disk creation
  master                        e4f05ba Imported Translations from Transifex
* stable/grizzly                159fdd2 Merge "Detach volume fails when using multipath iscsi" into stable/grizzly
  remotes/origin/HEAD           -> origin/master
  remotes/origin/master         e4f05ba Imported Translations from Transifex
  remotes/origin/stable/folsom  6740c41 Check QCOW2 image size during root disk creation
  remotes/origin/stable/grizzly 159fdd2 Merge "Detach volume fails when using multipath iscsi" into stable/grizzly

git branch -a
  folsom
  master
* stable/grizzly
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/stable/folsom
  remotes/origin/stable/grizzly

Once we are done with the checking out we can always get back to the most up to date and latest code.
 
git checkout master
Switched to branch 'master'

References
  1. http://git-scm.com/book/ch3-5.html
  2. http://stackoverflow.com/questions/9537392/git-fetch-remote-branch

No comments:

Post a Comment