Git drupal:// URLs for projects and sandboxes
In a previous post, I showed an example of cloning a module that included this command:
git clone drupal://drupalcs. But I neglected to explain how this worked. I'm not sure where I picked this up (it was probably from Sam Boyer), but by adding a few lines to your
~/.gitconfig makes checking out Drupal projects and sandboxes easier:
[url "ssh://email@example.com/project/"] insteadOf = "drupal:" [url "ssh://firstname.lastname@example.org/sandbox/"] insteadOf = "drupalsand:"
This allows you to use
drupal://PROJECT_NAME to identify a project (module, theme) git repository, and
drupalsand://USER/NID to checkout a sandbox. For example, I can clone one of my sandbox projects with this command, executed at the command line:
$ git clone drupalsand://mbutcher/1356522 Cloning into 1356522... remote: Counting objects: 988, done. remote: Compressing objects: 100% (466/466), done. remote: Total 988 (delta 463), reused 878 (delta 404) Receiving objects: 100% (988/988), 242.04 KiB | 354 KiB/s, done. Resolving deltas: 100% (463/463), done. warning: remote HEAD refers to nonexistent ref, unable to checkout.
Perhaps this sort of syntactic sugar isn't for everyone, but I find it to be a nice configuration short-cut. Of course, there's no reason you need to restrict this to Drupal. If you frequently use other Git remote repositories, a similar convention can be used for generating shortcuts. I have such shortcuts for HP's internal repos. And it would be easy enough to create a scheme like that for GitHub or other hosted repo sites.
If you're the one who came up with this scheme, let me know. I feel bad for not being able to give due credit.