Gold Apple Software Web Development by Geoff Appleby

Shortcut for cloning Drupal Git Repositories

Taken from a conversation on Groups.Drupal.org where several people shared some of their shortcuts for using git.  The following Bash function will clone a git repository from git.Drupal.org, and optionally set up and switch to a remote tracking branch of the specified version. 

function dclone() {
  git clone git://git.drupal.org/project/$1.git
  if [ -n "$2"]; then
    cd $1
    git checkout --track origin/$2
    cd ..
  fi
}

While the git-clone documentation specifies a --branch parameter, my server seems to have an older version of git which doesn't support it.  Therefore, creating the specified tracking branch is compeleted in a separate command.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <br> <p>
  • Lines and paragraphs break automatically.
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.