elasticsearch codebase is hosted on github, and its just a fork away. To get started with the code, start by either forking or cloning the repo. One can also just download the master code in either zip or tar.gz.
Once downloaded, building an elasticsearch distribution is simple. From within the source, run:
If you are running it for the first time, go get a cup of coffee (or better yet, a beer), it will take some time to download all the dependencies elasticsearch has. Once finished, a full distribution of the elasticsearch will be created under build/distributions.
In order to use it, just get either the zip or tar.gz installation, extract it, and fire up elasticsearch -f. You now have a fully functional master based elasticsearch version running.