Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clone the latest stable branch to a dir via github?

I want to clone the latest stable version of WordPress from Github, via a shell script. It is simple to get the unstable master branch:

git clone git://github.com/WordPress/WordPress.git

But how can I get the highest numbered stable release via a script, not manually checking out the code. E.g., using deployment shell script or deployment tool such as Fabric.

Edit: I clarified the text to better indicate the intent that I meant how to do this from a script, not manually.

like image 530
Dan Gayle Avatar asked Nov 17 '12 21:11

Dan Gayle


3 Answers

Clone from git and change to the WordPress directory

git clone git://github.com/WordPress/WordPress.git 
cd WordPress

Then list out the branches..

git branch -r 

This gives something like...

origin/1.5-branch   
origin/2.0-branch   
...
origin/3.4-branch  
origin/HEAD -> origin/master   
origin/master

Check out the branch you want...

git checkout 3.4-branch
Branch 3.4-branch set up to track remote branch 3.4-branch from origin.
Switched to a new branch '3.4-branch'
like image 165
Chris Carson Avatar answered Nov 19 '22 11:11

Chris Carson


Here's what I actually ended up doing, which is included in a Fabric fabfile I have on Github:

git clone git://github.com/WordPress/WordPress.git .
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))

It clones the repo like normal, then does some shell magic to find the latest tagged version of WordPress (Which is where the stable branches live.)

like image 45
Dan Gayle Avatar answered Nov 19 '22 13:11

Dan Gayle


Can you try a git checkout master ?

like image 1
Oleg Butuzov Avatar answered Nov 19 '22 13:11

Oleg Butuzov