Last updated July 16, 2015.
Once you have created a sandbox project or created a full project on Drupal.org and written code for this project, you can push your locally-saved code up to Drupal.org using Git. For step-by-step instructions on pushing your project code, visit your project's page on Drupal.org and click the Version control tab as shown below.
When you push code to Drupal.org, you are required to use Secure Shell protocol (SSH protocol). You must authenticate using SSH whenever you interact with the remote repository on Drupal.org, for example when using commands such as
git fetch, and
git pull. You can authenticate in one of two ways:
- Providing your Drupal.org password
- Providing SSH keys
Authenticating with your Drupal.org password
If you have not set up an SSH key in your Drupal.org account, Git will prompt you to authenticate using your Drupal.org password.
Authenticating with SSH Keys
The most common way to authenticate is using SSH keys. Although SSH keys are slightly more work to set up initially, they are far less hassle on a day-to-day basis. An SSH key is a pair of cryptgraphic keys consisting of a private key and a public key.
The private key must be kept strictly confidential. You keep it to yourself and never send it by email, etc. You need a private key on every computer/account where you will use Git.
Drupal.org allows you to use as many key pairs as you like. Thus, you can create a public/private key pair for each computer you use. But if you prefer using only one key pair for all of your computers, you can copy your private key to each of them.
You share the public key on code repositories such as GitHub, Drupal.org, or any other SSH server you use. When you try to connect to the repository, the SSH system checks if your (local) private key corresponds with any of the (remote) public keys Drupal.org has. If there is a match, access is granted. You can share your public key with anyone at any time without compromising security.
Generating your keys
Adding your public key to Drupal.org
- Visit your Drupal.org profile page
- Click the SSH keys sub-tab > Add a public key link. Paste into the Key field the public key you generated in the section above, Generating your keys.
- Click Save.
The first time you connect
Every time you connect to Drupal.org with SSH, the server will authenticate itself, too. The first time you connect, your system will not know Drupal.org's public key and you'll see a prompt like the following one.
Note: Be sure to type yes at the prompt rather than just pressing Enter.
Initialized empty Git repository in /project/example/.git/
The authenticity of host 'git.drupal.org (22.214.171.124)' can't be established.
RSA key fingerprint is 16:f5:44:6c:a1:c6:be:72:cd:98:b5:b7:7d:26:d6:14.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.drupal.org,126.96.36.199' (RSA) to the list of known hosts.
Frequently asked questions about SSH keys
What if I lose my private key?
You need to ask yourself if you are sure that nobody possesses your private key. If you are not sure, create a new pair of keys and replace the old ones.
What if somebody else may possess my private key?
Immediately go into your Drupal.org account and delete your public key in "Your Dashboard Profile: "SSH keys". Check all repositories you can write to for commits you didn't do.
Why do I need a username if I'm using SSH keys?
You don't! You can use also use the familiar email@example.com:project/[projectname].git. We don't document it in most instructions because our documentation tries to accommodate the least complex entry point. That means password-based authentication, which means using the Git username.
How do I initialize my SSH key on Windows with msysgit/cmd/cygwin/TortoiseGit?
If you installed Git/msysgit with the recommended "Use (Tortoise)Plink" option, after setting up your SSH keys, when trying to use git on the command line, you may get the following error:
# git clone [...] firstname.lastname@example.org:project/drupal.git
Cloning into drupal...
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 16:f5:44:6c:a1:c6:be:72:cd:98:b5:b7:7d:26:d6:14
fatal: The remote end hung up unexpectedly
To resolve this error:
- Start PuTTY
- Connect to host
- Confirm the host's signature/fingerprint
- Cancel the connection (
STRG + C)
- Done. git should be able to perform all operations regardless of shell now (regular Windows command prompt, msysgit, or cygwin)