Chapter 6. Working with GitHub

Because book files in Atlas are managed with git, you could easily sync those files with a repository on GitHub. This following video describes the overall flow of working with GitHub in Atlas:

The remainder of this chapter will give you step-by-step instructions:

If you’re totally new to GitHub, the best place to start is the GitHub help pages. They’ll walk you through what you need to know to set up an account, create a repo, set up your security credentials, and so on. Once you’ve got an account and have successfully completed the steps on setting up git, it’s pretty simple to move stuff back and forth between Atlas and GitHub.

To put your code on GitHub, first, create a new repository. You’ll be prompted to enter a name, a description, and whether you want to make the repo public or private (available only if you have a paid account). It will look very similar to Figure 6-1.

A screenshot of the GitHub interface
Figure 6-1. Create a new repository on GitHub

Once you create a project, you’ll see a screen that lists some helpful commands for what you’ll do next. Locate the “Existing Git Repo?” section and then find the line that looks like this:

$ git remote add origin git@github.com:MakerPress/new_project.git

It will look something like Figure 6-2.

A screenshot from GitHub showing where a user can find the project URL
Figure 6-2. The new repo’s URL appears in the “Existing Git Repo?” section

Once you’ve got the line, copy the repo’s url (in our example, it’s git@github.com:MakerPress/new_project.git) and enter the following command in the directory where your local Atlas repo is stored. (Note that the word "origin" is the only thing we’re changing from the original command.):

$ git remote add github git@github.com:MakerPress/new_project.git

Once you’ve set up the new remote, you can push to it with this command:

$ git push github master

You can then take full advantage of all the amazing features and community available on GitHub.

Conversely, if you already have a repo on GitHub that you’d like to pull into Atlas, all you have to do is clone it down and add a new remote to an Atlas repo, like this:

$ git clone git@github.com:MakerPress/new_project.git
Cloning into new_project...
warning: You appear to have cloned an empty repository.
admins-MacBook-Air-2:Desktop odewahn
$ cd new_project/
admins-MacBook-Air-2:new_project odewahn
$ git remote add atlas https://odewahn%40oreilly.com@atlas-
admin.oreilly.com/git/1230000000197.git
admins-MacBook-Air-2:new_project odewahn
$ git push atlas master
...

As we continue to improve Atlas, we’ll add features to allow you to easily move projects back and forth from within the UI.