3

There doesnt seem to be any good documentation on a quick way to git clone a module project. I have already read this: https://drupal.org/project/examples/git-instructions

The following format does not work for me:

git clone --branch 7.x-1.x http://git.drupal.org/project/examples.git

I am getting this error: enter image description here

Is there a way to do a git clone quickly by copying a url without having to put in --branch 7.x-1.x versions... or better yet is there a drush command to do a git clone? All i want to do right now is do a git clone of a project and provide a patch to the maintainer, but im hitting resistance setting this up.

1
  • There is something wrong with your local GIT setup. Specifically, it seems GIT is not able to execute the 'git-remote-http' command. Do you have any funky aliasing setup? I just tried your clone command on my local environment and it worked fine. Jun 27 '13 at 21:07
7

Just use the format you say doesn't work. This is the correct format. The URL does matter. (Do not use the format that produces the error.)

I.e. to clone branch 7.x-1.x of tb_megamenu, you should use:

git clone --branch 7.x-1.x http://git.drupal.org/project/tb_megamenu.git

You may skip the --branch option and branch identifier when cloning. This will clone the current HEAD, which may (or may not) be the head of the branch you want.

2
  • i copied the repo url "drupalcode.org" in my command. does that matter? or do i have to manually type git.drupal.org everytime? Jun 27 '13 at 21:55
  • 1
    The questioner states the git clone command doesn't work and wants to find a command where a branch option is not required in order to get the correct version. Also asked was "...is there a drush command to do a git clone." I don't know how this answer got accepted. Sep 5 '16 at 2:04
1

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.

If no --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.

Examples:

  • drush dl --package-handler=git_drupalorg examples Use git.drupal.org to checkout and update the Examples project.

Arguments:

  1. projects - A comma delimited list of drupal.org project names, with optional version. Defaults to 'drupal'

Options:

  • --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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.