Contribute Your Code on Drupal.org, Part 4: Connecting to the Sandbox

| Drupal
Contribute Your Code on Drupal.org, Part 4: Connecting to the Sandbox

Welcome to Part 4 of this series that shows how to start contributing modules and themes to Drupal.org.

In previous parts of this series, we talked about the different ways in which you can contribute to Drupal, setting up your project and configuring Git. 

Now we need to connect to our sandbox and test that it is working properly. To do this you need an SSH Key. If you're unsure about this, watch our class on SSH Keys

  • Go to Drupal.org and visit your account page.
  • Under the "Profile" submenu, you will see an option for "SSH Keys". Here you can see any existing keys and a link to Drupal's official help for setting up SSHKeys should you need extra support.

2 but 1

  • Go to Dashboard > Profile > Your Projects. You will see a list of your current Drupal.org projects.

1

Now move from the View page to the version control page and you should see instructions for using Git.

You should note that this page will change once you have successfully setup the project. Here are the commands I needed for the Breeze Project.

mkdir breeze 
cd breeze 
git init 
checkout -b 8.x-1.x 
echo "name = breeze " > breeze.info 
git add breeze.info git 
commit -m "Initial commit." git 
remote add origin YOURNAMEATDRUPAL@git.drupal.org:sandbox/ YOURNAMEATDRUPAL/PROJECTNUMBER.git 
git push origin 8.x-1.x

Please note that you need to make the required changes to the above code to make it match your user and project so for clarity I will explain these commands.

  • mkdir breeze = This makes a folder for the project. In this case, the folder is called breeze
  • cd breeze = enter the folder
  • git init = initialize Git
  • git checkout -b 8.x-1.x = Create a branch. This is set to 7 by default, so if you want to do a Drupal 8 module you must change the branch name.
  • echo "name = breeze " > breeze.info = Create demo file called breeze.info.
  • git add breeze.info = Add the demo file to the queue to be adding to the project.
  • commit -m "Initial commit." = Add information regarding the change. This will be expected with all changes because it is a good idea to tell users what the update refers to.
  • remote add origin = Add the changes.
  • git push origin 8.x-1.x = Apply the changes to the repository at Drupal.org

If the above fails you do not have your Git setup correctly and it is likely a problem with the SSH Key.

If you have tried to add a key previously you may experience key lock. You can fix this by running the following command in your terminal.

export GIT_SSH_COMMAND="ssh -oKexAlgorithms=+diffie-hellman-group1-sha1"

Now refresh the version control page and you should see it has updated. A new range of Git instructions and advice has appeared.

3

Now we have successfully connected git to Drupal's Git repository you can start building your module If you want to verify the files from a different machine:

  • Install and configure Git
  • Run the Git access clone commands from the Sandbox Project page. This was the command for
  • This was the command for the Breeze project as an example for what you should be looking for "Git clone http://git.drupal.org/sandbox/ikit-claw/2710867.git breeze". The addition of the Breeze will download the file into a new folder called Breeze.
  • Locate the file on your local drive. For me, it was under C:\Users\ using windows.

About the author

Daniel is a web designer from UK, who's a friendly and helpful part of the support team here at OSTraining.