An easier option I find is to use the Drush command
drush pm-download with the
--package-handler=git_drupalorg option. For the examples module given in your question you would run this command in a terminal:
drush pm-download --package-handler=git_drupalorg examples-7.x
Specifying the Drupal version in the argument above ensures the correct branch is checked-out after the project is cloned.
Here's the relevant documentation for the Drush command and options:
drush help pm-download
Download Drupal core or projects from drupal.org (Drupal core, modules, themes or profiles) and other sources. It will automatically figure out which project version you want based on its recommended release, or you may specify a particular version.
--destination is provided, then destination depends on the project type:
- Profiles will be downloaded to
profiles/ in your Drupal root.
- Modules and themes will be downloaded to the site specific directory (
sites/example.com/modules|themes) if available, or to the site wide directory otherwise.
- If you're downloading drupal core or you are not running the command within a bootstrapped drupal site, the default location is the current directory.
- Drush commands will be relocated to
/usr/share/drush/commands (if available) or
~/.drush. Relocation is determined once the project is downloaded by examining its content.
drush dl --package-handler=git_drupalorg examples Use git.drupal.org to checkout and update the Examples project.
projects - A comma delimited list of drupal.org project names, with optional version. Defaults to 'drupal'
--package-handler=git_drupalorg Use git.drupal.org to checkout and update projects.
--gitusername Your git username as shown on user/[uid]/edit/git. Typically, this is set this in drushrc.php. Omitting this prevents users from pushing changes back to git.drupal.org.
--gitsubmodule Use git submodules for checking out new projects. Existing git checkouts are unaffected, and will continue to (not) use submodules regardless of this setting.
--gitsubmoduleaddparams Add options to the
git submodule add command.
--gitcheckoutparams Add options to the
git checkout command.
--gitcloneparams Add options to the
git clone command.
--gitfetchparams Add options to the
git fetch command.
--gitpullparams Add options to the
git pull command.
--gitinfofile Inject version info into each .info file.