Most projects start with you trying out something locally, getting it working and then after some initial testing you might then want to publish the project on Drupal.org. Sandboxes are a great way to throw up some code and the perfect place to pop random code that others might find useful or a project that you just don't want to maintain. If you go and create one on Drupal.org then you'll get helpful instructions for creating a new git repository and creating a basic module to go in the repository and then pushing that code to Drupal.org's servers. But what if you have put your development in a local git repository already? Well, it's really simple to push that code up to a Drupal.org sandbox too, with the minimum of fuss.
Start by adding a remote to your local git repo:
# Replace USERNAME with your git username, and SANDBOX with your sandbox number.
git remote add origin [email protected]:sandbox/USERNAME/SANDBOX.git
Then you can push your local master branch into your sandbox by just doing:
git push -u origin master
-u options means that git will set your branch up to track the remote one, which will make future git pulls and pushes easier.
For extra bonus points, if you've been developing a 7.x version of your project, on a local master branch, but you don't want a master branch on Drupal.org then you could do this push instead:
git push origin master:7.x-1.x
Note that I've not used the
-u option here, as I'd probably bring down a tracking branch of the new 7.x-1.x branch next, and delete my local master branch.
git pull --track origin/7.x-1.x
git branch -d master